This error can be seen after redeployment of the API website in developer tools (F12)
This is a misleading error message; real underlying problem is application pool account for the API website does not have execute permissions on the API website’s folder.
The permissions problem can be seen by trying to open api website on the IIS Server hosting this website. If we try to send AJAX request to the API website on the hosting IIS server, the error message changes to
[Win32Exception (0x80004005): Access is denied]
[ExternalException (0x80004005): Cannot execute a program. The command being executed was "<path of the API website folder on server>/bin/csc.exe" /shared /keepalive:"10" /noconfig /fullpaths @"C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Temporary ASP.NET Files\root\5a229d66\a33ece8d\xf2kzry1.cmdline".]
This problem can be fixed by navigating to the IIS server and providing full control permissions for app pool account on the API Website folder.
If we don't want this issue to repeat after every deployment, we can add IncludeSetAclProviderOnDestination tag in the publish profile (.pubxml) file as explained at https://stackoverflow.com/questions/54911986/iis-application-pool-identity-permissions-reset-on-every-visual-studio-app-publi
"1.0" encoding="UTF-8" xml version= <Project xmlns="http://schemas.microsoft.com/developer/msbuild/2003" ToolsVersion="4.0"> <PropertyGroup> <IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination> </PropertyGroup> </Project>
This parameter can also be added to .csproj file or as msbuild parameter as exlpained at https://blogs.iis.net/msdeploy/skipping-setting-an-acl-in-a-visual-studio-2010-deployment-package
1) Edit the .csproj file and set <IncludeSetAclProviderOnDestination>False</IncludeSetAclProviderOnDestination>
2) msbuild.exe myproject.csproj /p:IncludeSetAclProviderOnDestination=False
Another way of specifying permissions is explained at https://davidsonsousa.net/blog/post/setting-folder-permissions-using-web-deploy
More references/options:
- https://docs.microsoft.com/en-us/answers/questions/202683/why-is-access-to-the-path-39binroslyn39-denied.html
- https://stackoverflow.com/questions/54893505/server-error-in-application-access-is-denied
- https://stackoverflow.com/questions/32780315/could-not-find-a-part-of-the-path-bin-roslyn-csc-exe