Getting System.Web.AspNetHostingPermissions error with local IIS application.

Last post 11-24-2009 7:20 PM by Doctor Who. 6 replies.

Sort Posts:

  • Getting System.Web.AspNetHostingPermissions error with local IIS application.

    10-26-2009, 7:48 PM
    • Member
      11 point Member
    • Doctor Who
    • Member since 07-11-2008, 6:25 PM
    • Posts 54

    I'm re-creating my development environment on my new Windows 7 machine.  I'm trying to move over some local ASP.NET apps I'd worked on, when I was using Vista.  All of these apps run in IIS on the local machine - no remote machine is involved.  And the ASP.NET AJAX Control Toolkit DLL is in the bin folder for the ASP.NET app.  Here's the error I'm getting:

     

    Security Exception

    Description: The application attempted to perform an operation not allowed by the security policy.  To grant this application the required permission please contact your system administrator or change the application's trust level in the configuration file.

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

    Source Error:

    An unhandled exception was generated during the execution of the current web request. Information regarding the origin and location of the exception can be identified using the exception stack trace below.

    Stack Trace:

    [SecurityException: Request for the permission of type 'System.Web.AspNetHostingPermission, System, Version=2.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089' failed.]
       System.Reflection.Assembly._GetType(String name, Boolean throwOnError, Boolean ignoreCase) +0
       System.Web.UI.NamespaceTagNameToTypeMapper.GetControlType(String tagName, IDictionary attribs, Boolean throwOnError) +209
    

    Doctor Who
  • Re: Getting System.Web.AspNetHostingPermissions error with local IIS application.

    10-30-2009, 5:42 AM

    Hi Doctor,

    To fix the issue, please use Code Access Security Policy to Constrain an Assembly.

    The following explains how to do this. Please refer to it:

    http://msdn.microsoft.com/en-us/library/aa302361.aspx

    Forward Sun
    Microsoft Online Community Support
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Getting System.Web.AspNetHostingPermissions error with local IIS application.

    10-31-2009, 11:11 AM
    • Member
      11 point Member
    • Doctor Who
    • Member since 07-11-2008, 6:25 PM
    • Posts 54

    Hi,

    I tried doing what you suggested, an it almost worked.  What stopped it was I got an error that said that it couldn't access a SQL database for membership.  I'm not really sure why it would want/need to have a SQL database for running ASP.NET AJAX code, but whatever.

    So this now leads me to thinking of what others have suggested I do, when I setup this machine.  I wanted to put the developer edition of SQL Server 2008 onto my machine and then VS 2008.  I was strongly advised to not put on SQL Server 2005 Express edition!  So, I didn't.  Now I think it wants SQL 2005 Express, because that's what VS 2008 uses (I think), when it's doing something with the AspNetSqlProvider.

    So this leads me to ask, do I install SQL 2005 Express, or SQL 2008 Express?  Which will Visual Studio 2008 work with?  Which does it need?  Must it be SQL 2005 Express, or can it be SQL 2008 Express?

     

    Doctor Who
  • Re: Getting System.Web.AspNetHostingPermissions error with local IIS application.

    11-02-2009, 5:32 AM

    Doctor Who:
    What stopped it was I got an error that said that it couldn't access a SQL database for membership. 
     

    Could you please post the detail exception message?

    If you host your project in IIS, I suggest you try to add the NT Authority\NETWORKER Services to SQL SERVER.

    Or go to the Internet Information Server Manager (IIS), open the DefaultAppPool Properties and choose Local System as the Predefined Security Account for the servers web apps.

    Gary yang - MSFT
    Microsoft Online Community Support

    Please remember to mark the replies as answers if they help and unmark them if they provide no help.
  • Re: Getting System.Web.AspNetHostingPermissions error with local IIS application.

    11-07-2009, 6:26 PM
    • Member
      11 point Member
    • Doctor Who
    • Member since 07-11-2008, 6:25 PM
    • Posts 54

    OK, when I go into the ASP.NET Configuration tool, it works fine, until I try to go to the Security tab.   When I try clicking on the Security tab I get the following error:


    There is a problem with your selected data store. This can be caused by an invalid server name or credentials, or by insufficient permission. It can also be caused by the role manager feature not being enabled. Click the button below to be redirected to a page where you can choose a new data store.

    The following message may help in diagnosing the problem: Unable to connect to SQL Server database.


    If I then

    click on the Choose Data Store button I get the following:

     


    Use this page to configure how Web site management data such as membership is stored. You can use a single provider for all the management data for your site or you can specify a different provider for each feature.

    Your application is currently configured to use the provider: AspNetSqlProvider

    Select a single provider for all site management data
    Select a different provider for each feature (advanced)


    So, what do you recommend I do, Gary Yang?

     

    Doctor Who
  • Re: Getting System.Web.AspNetHostingPermissions error with local IIS application.

    11-24-2009, 5:31 PM

    I found that on Windows 7, you have to "unblock" DLLs that you've downloaded from the internet when trying to run them with ASP.Net projects.

    Right-click on the one of the AJAX DLLs and get it's properties. At the bottom, there may be a Security block saying that this file has come from another computer. You can click the "Unblock" button and this may solve your problem. It has solved issues I was experiencing with the Codeplex Facebook Toolkit.

    Tom

  • Re: Getting System.Web.AspNetHostingPermissions error with local IIS application.

    11-24-2009, 7:20 PM
    • Member
      11 point Member
    • Doctor Who
    • Member since 07-11-2008, 6:25 PM
    • Posts 54

    WOW, Tom, you suggestion looked extremely promising.  I did as you said and found that the AjaxControlToolkit.dll did in fact has a security message saying that the file had come from another computer.  I "Unblocked" it, as you said.  And I also unblocked the AjaxControlToolkit.pdb file as well.  Unfortunately, I'm still getting the same error message.

    However, I am wondering if you're onto something there.  I've looked carefully at the Web.Config file and I don't see any reference to the AjaxControlToolkit, and I would have thought there would be one. 

    Doctor Who
Page 1 of 1 (7 items)