authentication mode error

Discussion in 'ASP .Net' started by Joe, Jan 11, 2006.

  1. Joe

    Joe Guest

    What I want to do is make only one page require a login. The application
    itself works fine.

    I'm getting the following error:
    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:


    Line 105: <location path="LoginTest.aspx">
    Line 106: <system.web>
    Line 107: <authentication mode="Forms">
    Line 108: <forms name=".ASPXAUTH" loginUrl="Login.aspx" timeout="30"/>
    Line 109: </authentication>

    Here's my config:
    <!-- *** This is the original lines **** -->
    <authentication mode="Forms">

    </authentication>

    <!-- AUTHORIZATION
    This section sets the authorization policies of the application.
    You can allow or deny access
    to application resources by user or role. Wildcards: "*" mean
    everyone, "?" means anonymous
    (unauthenticated) users.
    -->

    <authorization>
    <allow users="*" /> <!-- Allow all users -->
    <!-- <allow users="[comma separated list of users]"
    roles="[comma separated list of roles]"/>
    <deny users="[comma separated list of users]"
    roles="[comma separated list of roles]"/>
    -->
    </authorization>

    <!-- *** I added these lines at the end of my file just ahead of the closing
    </configuration> *** -->

    <location path="LoginTest.aspx">
    <system.web>
    <authentication mode="Forms">
    <forms name=".ASPXAUTH" loginUrl="Login.aspx" timeout="30"/>
    </authentication>

    <authorization>
    <deny users = "?"/>

    </authorization>
    </system.web>
    </location>

    If I comment out the <authentication mode="Forms"> section, I get my login
    screen but right after that I get the Windows login screen.

    Any ideas?

    Thanks,
    Joe
     
    Joe, Jan 11, 2006
    #1
    1. Advertising

  2. Hi Joe,

    Welcome to ASPNET newsgroup.
    As for the Authentication Mode error, it is because <authentication>
    setting is a MachineToApplication level setting which means it can only be
    configured at machine .config or only once in each asp.net application's
    main web.config. It can not be configured multiple times by using sub
    dir's web.config or the <location > element as you used....

    For your scenario, you'd like to grant access protection to an individule
    page (or a sub folder), we can configure using the <authorization> element
    , this is used for user or role based access permission to pages and can
    be configured for individual pages or sub dirs. e.g:

    <configuration>
    <location path="~/admin.aspx">
    <system.web>
    <authorization>
    <deny users="?"/>
    </authorization>
    </system.web>
    </location>


    #<authorization> Element
    http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpgenref/ht
    ml/gngrfauthorizationsection.asp

    Hope helps. Thanks,

    Steven Cheng
    Microsoft Online Support

    Get Secure! www.microsoft.com/security
    (This posting is provided "AS IS", with no warranties, and confers no
    rights.)




    --------------------
    | From: "Joe" <>
    | Subject: authentication mode error
    | Date: Wed, 11 Jan 2006 05:42:33 -0500
    | Lines: 66
    | X-Priority: 3
    | X-MSMail-Priority: Normal
    | X-Newsreader: Microsoft Outlook Express 6.00.2900.2180
    | X-RFC2646: Format=Flowed; Original
    | X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2900.2180
    | Message-ID: <>
    | Newsgroups: microsoft.public.dotnet.framework.aspnet
    | NNTP-Posting-Host: 69.37.58.70.adsl.snet.net 69.37.58.70
    | Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGP08.phx.gbl!TK2MSFTNGP12.phx.gbl
    | Xref: TK2MSFTNGXA02.phx.gbl
    microsoft.public.dotnet.framework.aspnet:370029
    | X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
    |
    | What I want to do is make only one page require a login. The application
    | itself works fine.
    |
    | I'm getting the following error:
    | 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:
    |
    |
    | Line 105: <location path="LoginTest.aspx">
    | Line 106: <system.web>
    | Line 107: <authentication mode="Forms">
    | Line 108: <forms name=".ASPXAUTH" loginUrl="Login.aspx" timeout="30"/>
    | Line 109: </authentication>
    |
    | Here's my config:
    | <!-- *** This is the original lines **** -->
    | <authentication mode="Forms">
    |
    | </authentication>
    |
    | <!-- AUTHORIZATION
    | This section sets the authorization policies of the
    application.
    | You can allow or deny access
    | to application resources by user or role. Wildcards: "*" mean
    | everyone, "?" means anonymous
    | (unauthenticated) users.
    | -->
    |
    | <authorization>
    | <allow users="*" /> <!-- Allow all users -->
    | <!-- <allow users="[comma separated list of users]"
    | roles="[comma separated list of roles]"/>
    | <deny users="[comma separated list of users]"
    | roles="[comma separated list of roles]"/>
    | -->
    | </authorization>
    |
    | <!-- *** I added these lines at the end of my file just ahead of the
    closing
    | </configuration> *** -->
    |
    | <location path="LoginTest.aspx">
    | <system.web>
    | <authentication mode="Forms">
    | <forms name=".ASPXAUTH" loginUrl="Login.aspx" timeout="30"/>
    | </authentication>
    |
    | <authorization>
    | <deny users = "?"/>
    |
    | </authorization>
    | </system.web>
    | </location>
    |
    | If I comment out the <authentication mode="Forms"> section, I get my
    login
    | screen but right after that I get the Windows login screen.
    |
    | Any ideas?
    |
    | Thanks,
    | Joe
    |
    |
    |
     
    Steven Cheng[MSFT], Jan 12, 2006
    #2
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. John J Lee
    Replies:
    3
    Views:
    492
    bruno at modulix
    Dec 1, 2005
  2. Edward Loper
    Replies:
    0
    Views:
    478
    Edward Loper
    Aug 7, 2007
  3. John J Lee
    Replies:
    0
    Views:
    531
    John J Lee
    Aug 7, 2007
  4. Edward Loper

    mmm-mode, python-mode and doctest-mode?

    Edward Loper, Aug 9, 2007, in forum: Python
    Replies:
    0
    Views:
    441
    Edward Loper
    Aug 9, 2007
  5. Neal Becker
    Replies:
    0
    Views:
    383
    Neal Becker
    Aug 9, 2007
Loading...

Share This Page