C# – Accessing Network Share from IIS .Net Application

asp.netciis-7

I have a stand-alone IIS7 Server that is not joined to a domain and that is running an simple ASP.Net application. This application has an ActiveReports report that has an image control where I set the path of the image during run time to a network share on another server. When I run the application locally in Visual Studio on a desktop that is joined to the same domain as the network share, I am able to get the images, but when I deploy the application to the stand-alone IIS server and run it locally on the IIS server I am not able to get the images. I added permissions on the network share for the username and password of the login for the IIS server and I am able to navigate using Windows Explorer to the network share from the IIS server now, but I can't get the permissions right on IIS.

What is the correct way to set the permissions so that the application can access the image files on the network share?

Best Answer

When IIS access network resources it uses the security context (account) associated with the IIS process. This is primarily controlled by the Application Pool unless you are doing any kind of impersonation at the code level.

In order to correct you issue you'll probably need to make sure the application pool is running using a security account that has access to the network resource. Here are some links that may help

http://technet.microsoft.com/en-us/library/cc771170(v=WS.10).aspx http://www.iis.net/learn/manage/configuring-security/application-pool-identities

Also, don't forget, if you are using windows file services for your network share there are two levels of permissions, those that are set at a share level and those that are set at the file level if using NTFS. Here is some info:

http://technet.microsoft.com/en-us/library/cc754178.aspx