AspNetHostingPermission Security Exception Fix in IIS7

I’m starting to regularly use the excellent ASP.NET Ajax Control Toolkit and had an interesting incident involving the toolkit last week on my home office Windows 2008 server.  Periodically when I loaded an Ajax Toolkit Control on my DBVT development site I would encounter a Security Exception on System.Web.AspNetHostingPermission. 

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

I didn’t encounter this with the toolkit on any other site. It would fix itself after touching the web.config, and it was in my development environment after all, but I still had to get to the bottom of it.  I stayed with it during down time over several days, trying various solutions with no success until I found an obscure reference in a DotNetNuke discussion thread.

"One suggestion I found was to change the thread pool to load the profile."

APPLICATION POOL!  Of course!  Whenever something inexplicable occurs, consider the application pool.  Here’s a screenpic of the IIS7 Application Pool settings running in Integrated Pipeline Mode.  Set "Load User Profile" to true.

You love me, I know.  You’re welcome! 

Article written by

A long time developer, I was an early adopter of Linux in the mid-90's for a few years until I entered corporate environments and worked with Microsoft technologies like ASP, then .NET. In 2008 I released Sueetie, an Online Community Platform built in .NET. In late 2012 I returned to my Linux roots and locked in on Java development. Much of my work is available on GitHub.