views:

32

answers:

2
+2  Q: 

asp mvc textreader

Hello, I am trying to use a textreader to retrieve data from a text file on a local machine. I have an upload routine to get the file for the reader to open.

When I run the application locally, it works fine. When I publish my application to my server, I am getting a Could not find a part of the path error. I assume this error has to do with permission in that the server cannot read from the local file system, but I don't know the proper way to remedy this.

do I set up the application to impersonate the user? I know I can't possibly set up each local users machine to allow the iusr account to access it.

Thanks for any thoughts.

UPDATE ** I ensured that network service is they user for the app pool. I also ensured that the networkService has access to the local folder that the application resides in. I am running IIS7, and when I test the site, I am getting the error -

The server is configured to use pass-through authentication with a built-in account to access the specified physical path. However, IIS Manager cannot verify whether the built-in account has access. Make sure that the application pool identity has Read access to the physical path. If this server is joined to a domain, and the application pool identity is NetworkService or LocalSystem, verify that <domain>\<computer_name>$ has Read access to the physical path. Then test these settings again

I have tried suggestions from various posts, including adding domain\servername$ to the folder to allow access, but nothing seems to work.

Any thoughts?

+1  A: 

Assuming this is IIS 6.5 or higher, the application pool user must have the necessary permission. By default, this is Network Service, which likely does not.

Tom Cabanski
necessary permission to what? the local user file system? It is defined network service.
czuroski
A: 

I solved this issue by first saving the file to the server, and then accessing the server's local file -

savedFileName = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, Path.GetFileName(file.FileName));
                    file.SaveAs(savedFileName);

The following blog helped me out - http://www.hanselman.com/blog/default.aspx?date=2008-06-28

czuroski