System.Web.AspNetHostingPermission Failed Error – .NET 2.0

I recently purchased some ASP.NET 2.0 components. One of these components is a report generation component. I was anxious to try it out since like the rest of you I always have a ton of reporting to create. So I plunked the control on the default.aspx page, set the parameters, one of which included a reference to the demo NWind.mdb database in my file system. When I went to build the site, I kept coming up with the System.Web.AspNetHostingPermission blah blah blah Failed error.

So of course, I turn to Google to try to solve the problem. Well I came up with tons of people who had this problem or some variant but not too many solutions. There was either no answer to the post or there was the security expert answer to the problem which involved a whole lot more theory than I wanted at the moment. I just wanted a simple solution to get a simple test program to complie and run.

Finally I got it. Here are the steps needed to fix the problem:

1) Run the MMC (Start -> Run -> MMC, Enter)

2) Add the Mscorcfg.msc snap-in which is a graphical interface to the .NET 2.0 Configuration Tool. (Select File -> Add/Remove Snap In …). Click the Add button and select .NET Framework 2.0 Configuration from the list of snap-ins that appear. Click the Add button.

3) Navigate to and click on Runtime Security Policy. Click on Adjust Zone Security.

4) In the window that pops up, select from either “Make changes to this computer” or “Make changes for the current user only”. In the next screen, select Intranet and move the slider to full. Close out of the windows as appropriate.

If you did all this while Visual Studio was open, close Visual Studio and reopen it. Compile your project and you should be good to go.

Advertisements

17 thoughts on “System.Web.AspNetHostingPermission Failed Error – .NET 2.0

  1. WOW. After searcing for a whole day here the solution. REALLY TANK YOU.

    I was having the same problem tryng FREETEXTBOX, and now i’ve the solution.
    Tanks again.

  2. Hi,
    Great article. Thanks.

    FYI I just ran the “Microsoft .NET Framework 2.0 Configuration” app directly instead of steps 1 and 2 above.

    The above solution did not fix my System.Web.AspNetHostingPermission blah blah blah Failed error. To fix my error i had to give Full control to Internet Zone which i didnt really want to do. My situation (for others) was i was mapping an IIS virtual directory to a path on my PC that was not physically under c:\inetpub\wwwroot e.g. P:\is\MyApp – in the browser i noticed the zone changed from Local Intranet to Internet and back to Local Intranet. Allowing Full control to Internet is the only current solution i have for this – note if the physical dir is under wwwroot the problem does not surface. Thanks again.

  3. Thanks alot !

    I just faced this problem today first time and I spend 3 hours to search the search the solution. Finally I find this page. Thanks again for saving my time.

  4. That right! It works.
    I had the problem after installing The Ajax Control Toolkit from ASP.NET.
    Following this guide solved my problem.
    Thanks a Lot!

    Koen

  5. Johnny B: I had the same issue.
    I solved it like this:
    First open Runtime Security Policy->Machine->Code Groups.

    Then rightclick “All_Code” and choose “New…” in the popupmenu.

    Enter a suatable name and click next.

    In the condition type dropdown choose URL. and in the URL textfield enter the url to your site followed by “/*”. Click next.

    Select “full trust” in the dropdown. Click next and then Finish

  6. Thank you! You’re dead on – lots of people with the problem, no solutions; saved me wasting a lot more time and I learned something.

  7. I’m also hours into the problem, but this did not work for me.
    I am trying to install the AjaxControlToolkit in Visual Studio 2008 in Windows XP. The dll shows up in the Project Explorer. But I can not add it to the toolbox.

    MMC won’t let me add .net framework 2.0 config , but it did let me add .net 1.1 framework config which seems to work the same way. (I have .net framework 3.5 sp1 installed). I easily followed instructions, but I still get “aspnethostingpermission failed”.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s