1
votes

I have a web application developed in ASP.net 4.0 and hosted in IIS7(ProdServer). In one of the pages I am creating a file and storing it in \someOtherServer\Storage\ folder.

when I log on to production server and hit run and \someOtherServer\Storage\ I am able to browse the folder.

When I run my ASP.net application I get the error Access to the path '0' is denied.

Exception Details: System.UnauthorizedAccessException: Access to the path '0' is denied.

ASP.NET is not authorized to access the requested resource. Consider granting access rights to the resource to the ASP.NET request identity. ASP.NET has a base process identity (typically {MACHINE}\ASPNET on IIS 5 or Network Service on IIS 6 and IIS 7, and the configured application pool identity on IIS 7.5) that is used if the application is not impersonating. If the application is impersonating via , the identity will be the anonymous user (typically IUSR_MACHINENAME) or the authenticated request user.

To grant ASP.NET access to a file, right-click the file in Explorer, choose "Properties" and select the Security tab. Click "Add" to add the appropriate user or group. Highlight the ASP.NET account, and check the boxes for the desired access.

1

1 Answers

5
votes

You will have to look at the identity of the apppool under which your ASP.net site is running and make sure that account has permissions to the resource on the other server.

To do this in IIS 7, do the following:

  • Open IIS manager and browse to the site where this is happening.
  • Right click on the site and select Manage Application -> Advanced settings.
  • The top most setting will show the name of the application pool you are running under. Most probably it is DefaultAppPool, but it could be something else too (preferably it should be something else).
  • Now cancel and click on the Application Pools node in IIS manager and right click on the application pool you saw above and select advanced settings.
  • Look at the Identity setting under process model - this might be ApplicationPoolIdentity. For you to access a resource on another machine you will have to run it either as NetworkService or as a domain account. I suggest you try the one and then the other. The domain account should be a service account which password does not expire (otherwise every time it expires you will have to retype it in here). Make sure that the domain account has access to the shared resource on the remote server.

Hope that helps someone.