The application attempted to perform an operation not allowed by the security policy .net framework2.0

The application attempted to perform an operation not allowed by the security policy .net framework2.0

Unable to read the security policy file for trust level ‘full’.

How to set ASP.NET hosting trust level

System.Security.SecurityException: Request for the permission of type ‘System.Web.AspNetHostingPermission

The application attempted to perform an operation not allowed by the security policy .net framework2.0

This error can occur if you are trying to configure a virtual directory or web application on IIS with remote resources. I would like to clear about few things first. You are using IIS7.5 and trying to create a virtual directory or web application. The web application’s data is placed on a shared network place. That shared place is accessible to specific users. You have configure that specific user in IIS7.5 Application Pool. Same user is configured in the web application to access. The IIS shows no error or warning while exploring the resources. Still you are getting the above errors.

Full Trust policy update for the adding a virtual directory with remote data is configured in the IIS and web.config file has all the required information.

Solution!

This solution worked for me on windows 2008 is pretty simple but its a command. please follow the under listed command to execute on your server where you are creating the web application. This web application will user the resources from a remote location in your network.

:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url “file:////\\server-name\share-name\*” FullTrust -exclusive on

I was using an old application which was developed in Microsoft Dot Net framework 2.0. change it according to your needs. once you are done, your application will start working. I tried this solution in my test environment and there was no security breach issues as well. Make sure you know what you are doing before following this article. I would love to hear the comments for this post. Follow us in Facebook. https://www.facebook.com/WindowsTechUpdates

Please share the post with your contacts.

Leave a Comment

This site uses Akismet to reduce spam. Learn how your comment data is processed.