1

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.

8
  • What account is your asp.net running as? Is it localservice for example? Commented Apr 13, 2011 at 16:18
  • Right now I"m testing on dev machine. How to check? Commented Apr 13, 2011 at 16:19
  • Depends what server you are using :) Cassini, iis, iis express, etc. Perhaps first though: in exacty what code are you using \\server\share ? Can you show? Commented Apr 13, 2011 at 16:22
  • I'm curious about your answer to Marc's question. Response.Redirect is a browser directive to fetch a different resource. The asp.net worker process isn't actually touching the share, it's just telling the client to do so. This of course begs the question of what it is you've told the browser to do, and whether that would be legit outside the context of your application. The "ShowPdf1.Filepath" is suspect. What happens if you don't include that? Commented Apr 13, 2011 at 16:31
  • 1
    Just because the share has read permissions doesn't mean the webserver has permissions to venture off the box. The webserver is sandboxed. If you're using the dev tools of VS then it should work if you can open the file. But for IIS you'll have to configure something differently. Can you share the code for what ShowPdf1 does with the filepath? (also, MarcGravell is like a friggin boss on C# so I would really really listen to him [he writes this site]) Commented Apr 13, 2011 at 17:13

2 Answers 2

0

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.

Sign up to request clarification or add additional context in comments.

18 Comments

How to set this in my dev environment?
right click on shared folder --> Web Sharig and then make it Virtual Directory
Share is on Windows 2000 Server. No Web Sharing option.
on your server, IIS Installed ?
The site is served from a different server. Which server do I need to create the virtual directory on?
|
0

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

3 Comments

Won't changing the password to IUSR_MACHINENAME have side-effects?
Plus, even if I do all of this, it doesn't explain why my code fails in Visual Studio dev server.
@MAW yes, changing the password to IUSR_XXX will have side effects. I think there are other avenues to explore first.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.