I am trying to connect the remote shared path from my application and read the file data using FileStream. The application has been hosted in IIS 8.5. I have added IUSR, Network Service, IIS_IUSRS and iis apppool\apppoolname under security tab of the hosted application folder and given full control access for the group names, user names and apppool.

FileStream fileStream = new FileStream(filePath, FileMode.Open, FileAccess.Read); 

Shall I create service account inside server and give the read permission to the remote shared path? Is this approach correct because we have to do periodic administrative action to maintain the account password or any other alternative approaches available to access the remote shared path from the application hosted in IIS?

The detail error message is as below.

Description: An unhandled exception occurred during the execution of the current web request. Please review the stack trace for more information about the error and where it originated in the code.

Exception Details: System.UnauthorizedAccessException: Access to the path 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 File 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.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.