Shane Bartholomeusz

Geek and lover of all things tech related

Resolve “AspNetHostingPermission” error

So what do you do if you come across this error in Visual Studio?

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

The error typically occurs when you download files from an external source into your Visual Studio project. Windows will recognise the file came from an external source and restrict permissions.

You can resolve this by viewing the file Properties for the offending file in Windows Explorer and clicking the “Unblock” button.

File properties

So what happens if you have lots of files and you need to do a bulk update? Well you can use the caspol.exe command line utility bundled with the .Net framework.

E.g.

C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "c:\myaspnetproject\*" FullTrust -exclusive on
Shane Bartholomeusz

Leave a Reply

© 2024 Shane Bartholomeusz

Theme by Anders NorenUp ↑