You may see “Access to the path is denied” error if the application is not able access to a path that is trying to read or write. This will show up as 401 Unauthorized error in IIS logs.
The error message:
Access to the path ‘C:\Windows\SysWOW64\inetsrv’ 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: Access to the path ‘C:\Windows\SysWOW64\inetsrv’ is denied.
Background As the error message implies, the folder is not accessible. The check would be the Security permissions for the folder stated in the error message above. Your web application’s apppool identity should have permission to this folder. In my case, the error message referred to C:\Windows\SysWOW64\inetsrv folder.
How to solve “Access to the path is denied” errors Open IIS Manager
Go to “Server > Application pools”
Note the value in “Identity” column for the application pool you are using
Go to one folder above (C:\Windows\SysWOW64)
Right click and select “Properties” for the folder (inetsrv)
Give “Full Control” permission to the application pool identity (In my case, I gave permission to “Network Service”)
If permissions assignment doesn’t work, I recommend enabling “32-bit Applications” for the application pool. Disabling Impersonation may help fixing this issue as well.