Access to the path … App_Code.compiled is denied

Try to Build and Compile and ASP.Net web application using impersonation.

Your Web.Config contains:

<identity impersonate="true" userName="Domain\ImpersonatedAccount" password="ImpersonatedPassword" />


Access to the path ‘C:\whatever\App_Code.compiled’ is denied.


Microsoft decided that ASP.NET compiles under the identity of the app’s process (derp).

Solution 1:

Remove the identity impersonate line from the Web.Config

Solution 2:

Grant required privileges, policies and access to the impersonated account.

At the command line:

net localgroup Administrators /add Domain\ImpersonatedAccount

ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeDebugPrivilege
ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeCreateTokenPrivilege
ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeAssignPrimaryTokenPrivilege
ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeBatchLogonRight
ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeServiceLogonRight
ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeImpersonatePrivilege
ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeInteractiveLogonRight
ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeChangeNotifyPrivilege
ntrights -u "Domain\ImpersonatedAccount" -m \\MyComputer +r SeIncreaseQuotaPrivilege

%windir%\\framework\v4.0.30319\aspnet_regiis.exe -ga Domain\ImpersonatedAccount


Leave a Reply

Fill in your details below or click an icon to log in: Logo

You are commenting using your account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s