How to download a file from a UNC mapped share via IIS and ASP
Posted
by helgeg
on Stack Overflow
See other posts from Stack Overflow
or by helgeg
Published on 2010-04-24T17:15:59Z
Indexed on
2010/04/24
17:23 UTC
Read the original article
Hit count: 261
I am writing an ASP application that will serve files to clients through the browser. The files are located on a file server that is available from the machine IIS is running on via a UNC path (\server\some\path).
I want to use something like the code below to serve the file. Serving files that are local to the machine IIS is running on is working well with this method, my trouble is being able to serve files from the UNC mapped share:
//Set the appropriate ContentType.
Response.ContentType = "Application/pdf";
//Get the physical path to the file.
string FilePath = MapPath("acrobat.pdf");
//Write the file directly to the HTTP content output stream.
Response.WriteFile(FilePath);
Response.End();
My question is how I can specify a UNC path for the file name. Also, to access the file share I need to connect with a specific username/password.
I would appreciate some pointers on how I can achieve this (either using the approach above or by other means).
© Stack Overflow or respective owner