Shane Bartholomeusz

Technical Solutions Consultant

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=, 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.


C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727\caspol.exe -m -ag 1 -url "c:\myaspnetproject\*" FullTrust -exclusive on
Shane Bartholomeusz
Latest posts by Shane Bartholomeusz (see all)

Leave a Reply

© 2020 Shane Bartholomeusz

Theme by Anders NorenUp ↑