You have a custom ASP.NET code depolying to the sharepoint area. You have added the strong named assembly to the GAC (or) 80/bin. After the iisreset (or) application recycle you see the following error:
Security ExceptionDescription: 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.Net.WebPermission, System, Version=22.214.171.124, Culture=neutral, PublicKeyToken=b77a5c561934e089′ failed.
An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.
Reason: .NETCAS( Code Access Security) restricts the managed code at the sharepoint cost!
Very simple than you imagined!
- On the sharepoint server, Go to the folder "C:\Program Files\Common Files\Microsoft Shared\web server extensions\12\CONFIG"
- Open the config file "wss_minimaltrust.config"
Under the XML section <namedpermissionsets> and under the last <permissionset> add the following:
<IPermission class="System.Net.WebPermission, System, Version=126.96.36.199, Culture=neutral, PublicKeyToken=b77a5c561934e089"
- You are all set. (No iisreset/app pool recycle is needed)