Windows 2008 IIS .Net SecurityException


I was attempting to install a .Net 3.5 application written in C# onto a Windows 2008 Enterprise R2 (64 bit) virtualized system.  What makes this a little unique is that the ASP.Net code is stored on a UNC file share.  Because of this issue, I received the following error:

Security Exception
Description: The application attempted to perform an operation not allowed by the security policy. To grant this application the required permission please contact your system administrator or change the application’s trust level in the configuration file.

Exception Details: System.Security.SecurityException: Request for the permission of type ‘System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.

Initially I was baffled and with enough searching I came across the “caspol” solution from Microsoft.

Which in essence is:

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\\fs\share\*" FullTrust -exclusive on

And of course, this doesn’t work! I had overlooked that inside each .Net framework directory (yes there are two on 64 bit systems) is a separate configuration file.

By running the 64 bit caspol.exe command, I was able to quickly fix the issue.

C:\WINDOWS\Microsoft.NET\Framework64\v2.0.50727\caspol.exe -m -ag 1 -url "file:////\\fs\share\*" FullTrust -exclusive on

I restarted the IIS service for good measure and we’re off to the races.

, , , , ,

  1. No comments yet.
(will not be published)


  1. No trackbacks yet.