Warm tip: This article is reproduced from stackoverflow.com, please click
silverlight

Problem with navigateurl in silverlight to a UNC path

发布于 2020-03-27 10:18:00

I have a problem with a command button (implementing the ICommand). I want, when pressing the specified button to redirect the user at new tab targeting a UNC path.

HtmlPage.Window.Navigate(new Uri(@"\\host\filename"), "_blank");

The problem is that browser redirects the user to the following target, besides of my intention:

http://www.hostnameoftheslapplication.com/\\host\filename

How can I achieve the correct navigation;

Thank you in advance.

Questioner
Aggelos Biboudis
Viewed
42
Tim Trout 2010-05-22 23:18

What you are trying to do is not allowed in Silverlight. HTML navigation is for opening web pages from web servers, but the UNC syntax you are providing is for file system access. Silverlight only allows extrememly limited access to the filesystem of the client PC.

To be able to serve up your file, you could configure your web server so that the "host" path was a virtual directory within your web application. Then you could use relative URI syntax to serve up the filename rather than UNC syntax.