Sunday, March 13, 2011

Security Exception: The application attempted to perform an operation not allowed by the security policy

While Working on a VisualWebPart with Telerik Controls I got a Security Exception. I searched many blogs and articles, and found some information for configuring Trust Level for Code in Microsoft .NET Framework 2.0 Configuration (can be found in Administration Tools, if the .Net Framework SDK 2.0 is installed in your machine) section. But, unfortunately it didn't help me much. Finally I tried in IIS Trust Level settings and changed it to Medium level that worked just fine. Thought it helps other so posted here, below are the details of it.

Environment I tried:
SharePoint 2010, IIS 7, Telerik Controls (2010 -3 - 1317)
Error 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.



Solution (It worked for me):
Step 1:
       Go to IIS and select the webapplication you are trying (like SharePoint - 80, in my case).

Step 2:
       In the right side window you can find the options like below, select .Net Trust Levels
Step 3:
      Select the Trust Level to Medium like below.


Step 4:
     Click on Apply to commit the changes, like shown below (it resides in the same window at the right - top)
Now try in your page, the error should go away ( if the problem is with this).


Another Solution FromTelerik Site:
Cause:
Microsoft changed the default setting of the Load User Profile setting of the application pools in Windows 7 and Windows 2008 (the old was True, in IIS7.5 it is False).
Suggested solution:
Open the Advanced Settings of the Application Pool (for the web app you are using) and set the Load User Profile property to True.
Source Link: http://www.telerik.com/help/aspnet-ajax/troubleshooting.html

Other Useful Posts:

Access to XMLHttpRequest at 'from origin has been blocked by CORS policy: Cross origin requests are only supported for protocol schemes: http, data, chrome, chrome-extension, https. .net core angular

Issue: The angular application was getting error from API that the origin has been blocked by CORS policy. Solution: Make sure that the...