问题
I have an asp.net webform which will display a PDF file. This pdf is stored on a network share on another server. The share has read permissions for everyone.
When I try to reference like \\server\sharename\file.pdf I get the following error:
Server Error in '/NCLWeb' Application.
HTTP Error 400 - Bad Request.
I've also tried variation with "file://" in front, and reversing the slashes. What am I doing wrong?
How should I properly reference this?
EDIT: I am testing the code using Visual Studio's built in development server. Code usage includes:
Response.Redirect(@\\server\sharename\file.pdf);
ShowPdf1.FilePath = @\\server\sharename\file.pdf;
Where ShowPdf1 is a control which I've used to display pdf's in a browser before.
回答1:
I doubt that folder is a Virtual Directory. If you want to access any shared folder from your application you need to make a Virtual Directory
of that Folder.
回答2:
Asp.net worker process needs permission to read network resources
check out article on code project(it was written in 2007) but it has basics written down step by step. http://www.codeproject.com/KB/aspnet/UNC__Access_Network_file.aspx
here is KB from microsoft http://support.microsoft.com/kb/207671
hope it helps
来源:https://stackoverflow.com/questions/5652326/trouble-accessing-network-share-from-asp-net-web-form