1

I need to provide a way for corporate users to view/download an excel file that's located on a network share. I'm sure that IIS has read access to that location, and I can navigate to it via the browser like so: \corp.it.com\root\shared\test.xls

But for the life of me I can't get this to work with an href or a hyperlink or a response.redirect. I've tried a bunch of different things - slashes in both directions, prefacing it with file://, but no luck. I've also tried impersonating a valid user and I can read/copy the file from my code, but I can't use that impersonation to actually navigate to that location.

Any thoughts?

Thanks.

user948060
  • 953
  • 3
  • 12
  • 25
  • This shouldn't need to go anywhere near IIS, you just need a correctly formatted `file://...` URI: `file://///server/share/file.txt` (taken from [various pages found on google](https://www.google.co.uk/search?q=UNC+file%3A%2F%2F&sourceid=ie7&rls=com.microsoft:en-GB:IE-Address&ie=&oe=&redir_esc=&ei=wUQQUZC6LIOc0QW0xYG4BA)) – Deanna Feb 04 '13 at 23:33
  • 1
    @Deanna: Most browsers nowadays will refuse to navigate to `file://` URIs from HTTP/S pages. –  Feb 04 '13 at 23:38
  • See also [Firefox Links to local or network pages do not work](http://stackoverflow.com/q/192080/588306) – Deanna Feb 05 '13 at 10:26

1 Answers1

0

This shouldn't involve IIS at all, you just need a correctly formatted file://... URL. As the spec is file://machinepathisvalidfrom/path, you can omit the machinepathisvalidfrom as localhost is implied but you MUST leave the \s in place. This leaves file:\\\ followed by the UNC with / changed to \:

file://///server/share/file.txt

Note that this can be browser dependant.

See the file:// spec, and other sources

Deanna
  • 23,876
  • 7
  • 71
  • 156
  • See duskwuff's response above, re most browsers refusing to navigate to file:// URls. That's what I'm finding. – user948060 Feb 05 '13 at 00:04
  • I also mentioned that and some examples (with workarounds IIRC) were mentioned in one of the given links on sites like [this for FireFox](http://rubenlaguna.com/wp/2007/04/20/firefox-and-file-windows-unc-paths/). As you hadn't mentioned any particular browser, the only thing I could post was the best case option using the default browser and a note saying it may not work in other browsers. – Deanna Feb 05 '13 at 10:22
  • Got it. I need a solution for all browsers though. – user948060 Feb 05 '13 at 16:21
  • @user948060 Your corporate office network isn't a controlled environment? :p – Deanna Feb 05 '13 at 16:42