system.unauthorizedaccessexception access to the path .net core Edit

Murugan Andezuthu Dharmaratnam | 18 March 2021 | 70

In my asp .net core 5.0 MVC application, everything was working fine while I was running the app using visual studio. But I get this error system.unauthorizedaccessexception access to the path when I deployed to the server on iis. Specifically, I was getting this error when I was trying to create a folder using code.

Solution

The solution was simple. The only thing I had to do was to give full permission to wwwroot folder.

  • go to root folder where application is loade
  • right click on wwwroot folder and select properties
  • go to security tab
  • select IIS_IUSRS and click on edit
  • select IIS_IUSRS
  • on the Permission for IIS_IUSRS
  • check and Give full permission