Search code examples
c#asp.netshared-directory

Trouble accessing network share from asp.net web form


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.


Solution

  • 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.