“Access to the path is denied” error is one of the most common issues ASP.NET developers come across while working with network resources in their applications. There is no straightforward solution to this problem. However, there are several things you should check to solve it.
Server Error in ‘/’ Application.
Access to the path X is denied.
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
Looking for best practices for session state and cookies in ASP.NET applications? Check this post out.
Solution for “Access to the path is denied” error
The root cause is that the application pool which is hosting your web application is not able to access to the shared folder you specified in your code. Therefore, it throws “Access to the path is denied” message.
Go through the recommendations below to find out why the application pool can’t access to the network resource.
- Did you give “Security” and “Sharing” permissions to the application pool identity? Make sure the account has required permissions in both tabs.
If there is no “Sharing” tab:
– Open Registry Editor (Start > Run > regedit)
– Take a backup of Registry (File > Export) to an external storage
If the folder does not exist, create it.
– There should be a (Default) value with type
The Data is blank? Double click on it and paste in
The “Sharing” tab is still not displayed? Go to “Folder Options“. Check “Use Sharing Wizard (Recommended)“
Still not displayed? In regedit, find
HKLM\System\CCS\Control\Lsa\forceguest. Modify the
forceguestentry value to
- Is impersonation enabled? In order to check it: “IIS Manager > Server name > Sites > Site name > Authentication > ASP.NET Impersonation”. If impersonation is enabled, impersonated user(s) will need permission on the shared folder.
- Do you have a virtual directory? If any virtual directories are used, please make sure they use application pool identity account in their pass-through authentication settings.
More to consider
- After making changes to application pool identity, please make sure to recycle , stop, and then start the application pool.
- Are you able to open the shared folder in your web server by using the credentials of application pool identity account? Check it: “Start > Run > \\server-name\shared-folder”.
- In the server that hosts the shared folder, check for failed logon attempts to see which user was used to access to shared folder. In order to check it: “Start > Event Viewer > Windows Logs > Security > Audit Failure“.
Are you using
ApplicationPoolIdentityto run your application pools? In this case, you should give permission to
COMPUTER$account on the network resource.
In conclusion, your effort to solve this problem should focus on the application pool identity account and shared folder permission. If you are still not able to solve the problem, please leave a comment here.
2 thoughts on “Access to the path is denied (Solved)”
I tried to upload a CV word file to website for job application, I got this message:
Access to the path ‘D:\Websites\GIU\docs\content\career\cv\c12b3f1337174430839675ebccc15b95.docx’ is denied
I don’t know how to resolve it
the site for the job vacancies
I’ll apricate helping me to solve this issue.