Help / It is an error to use a section registered as allowDefinition='MachineToApplication' beyond

Discussion in 'ASP.NET / ASP.NET Core' started by lu8890, Feb 25, 2005.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. Hi:

    I created and hosting an asp.net site on my own at home.
    In my asp.net app, I allow any use to access my webformswithout any security check. So I set my IIS setting to allow anonymous user, and setup the web.config of the rootdir of my app to <authentication mode="Windows">.

    And then I tried to create some webforms in the same app for restricted access only, so I created a new folder in the rootdir, and move all the webforms that I want to use for restrict access to the new folder. I then created a web.config in this directory, and change the following setting:

    <authentication mode="Forms">
    <forms loginUrl="..\login.aspx" />

    then when I test the app, everything still working just fine on the public accessible webforms.
    but when I tried to access the webforms in the new directory (the ones I intened to prompt for login), it failed with the following message:


    Server Error in '/' Application.


    Configuration Error
    Description: An error occurred during the processing of a configuration file required to service this request. Please review the specific error details below and modify your configuration file appropriately.

    Parser Error Message: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS.

    Source Error:






    Code:
    Line 45:     -->
    Line 46:     <!-- <authentication mode="Windows" /> -->
    Line 47:     <authentication mode="Forms">
    Line 48:     
    Line 49:     <forms loginUrl="..\login.aspx"
    Source File: C:\Inetpub\wwwroot\luwebserver\secure\web.config Line: 47





    Version Information:Microsoft .NET Framework Version:1.1.4322.573; ASP.NET Version:1.1.4322.573

    I've tried to research error, it seems like the same error message has been occured in several occasion, but non matches my scenario. I'd be very appreciated if anyone has any comment or suggestions.

    Thank you all in advance. :)

    Sincerely

    Tommy<!--
    [ConfigurationException]: It is an error to use a section registered as allowDefinition='MachineToApplication' beyond application level. This error can be caused by a virtual directory not being configured as an application in IIS. (C:\Inetpub\wwwroot\luwebserver\secure\web.config line 47)
    at System.Web.Configuration.HttpConfigurationSystem.CacheLookup(String vpath)
    at System.Web.Configuration.HttpConfigurationSystem.ComposeConfig(String reqPath, IHttpMapPath configmap)
    at System.Web.HttpContext.GetCompleteConfigRecord(String reqpath, IHttpMapPath configmap)
    at System.Web.HttpContext.GetCompleteConfig()
    at System.Web.HttpContext.GetConfig(String name)
    at System.Web.HttpContext.GetLKGConfig(String name)
    -->
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    you gotta set up the virtual directory as an application/

    Bruce

    DiscountASP.NET
    www.DiscountASP.NET
     
  3. Hi Bruce:


    Thank you very much for your response.


    I've finally figured out what went wrong.


    it turns out <authentication> tag can not be applied on sub-directory's web.config.


    To accomplish what I am trying to do, it will have to set authentication mode="Forms" in root dir's web.config level, and specify the loginURL attribute there.


    Then create another web.config in the sub-dir and include ONLY <authrization> tag to block out anonymous users to access webforms in that subdir without proper cookie attached. It is working for me now. :)


    once again, thank you very much for your time replying.


    This is my first time here in this community, and this place is really cool!! :)





    Tommy
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page