Different login page for each document...

Discussion in 'ASP .Net' started by =?Utf-8?B?U0I=?=, Jan 19, 2005.

  1. Hi
    I'm trying to get forms-based authentication to authenticate different users
    for differet pages, like this:

    <configuration>
    <location path="Member" allowOverride="true">
    <system.web>
    <authorization>
    <!-- allow tags must be first -->
    <allow users="Admin"/>
    <allow users="User"/>
    <deny users="*"/>
    </authorization>
    <authentication mode="Forms">
    <forms
    name="MyWebsiteCookieName"
    loginUrl="LoginPage1.aspx"
    protection="All"
    timeout="180"
    />
    </authentication>
    </system.web>
    </location>
    <location path="Admin" allowOverride="true">
    <system.web>
    <authorization>
    <!-- allow tags must be first -->
    <allow users="Admin"/>
    <deny users="*"/>
    </authorization>
    <authentication mode="Forms">
    <forms
    name="MyWebsiteCookieName"
    loginUrl="LoginPage2.aspx"
    protection="All"
    timeout="180"
    />
    </authentication>
    </system.web>
    </location>
    </configuration>

    But here I get this error:
    It is an error to use a section registered as
    allowDefinition='MachineToApplication' beyond application level.

    Many thanks for your help
    Simon
    =?Utf-8?B?U0I=?=, Jan 19, 2005
    #1
    1. Advertising

  2. Hi Simon,

    This error would normally indicate that the Virtual Directory for your web
    is not set up properly.

    1. Go to Start - Settings - Control Panel - Administrative Tools - Internet
    Information Services
    2. Expand the nodes to see Default Web Site

    Do you have node for your web site? If so check the properties or if you are
    not sure about this delete it. If it is not there do the following:

    3. Right-click the Default Web Site node to bring up the menu and select
    New - Virtual Directory
    4. Create a new virtual directory and the location is the folder location of
    your files..

    Try it again. If this isn't the problem and you still get the same error,
    I'll look in more detail at your web.config entries.

    Regards,

    Stuart
    MCSD, MCT


    "SB" <> wrote in message
    news:...
    > Hi
    > I'm trying to get forms-based authentication to authenticate different
    > users
    > for differet pages, like this:
    >
    > <configuration>
    > <location path="Member" allowOverride="true">
    > <system.web>
    > <authorization>
    > <!-- allow tags must be first -->
    > <allow users="Admin"/>
    > <allow users="User"/>
    > <deny users="*"/>
    > </authorization>
    > <authentication mode="Forms">
    > <forms
    > name="MyWebsiteCookieName"
    > loginUrl="LoginPage1.aspx"
    > protection="All"
    > timeout="180"
    > />
    > </authentication>
    > </system.web>
    > </location>
    > <location path="Admin" allowOverride="true">
    > <system.web>
    > <authorization>
    > <!-- allow tags must be first -->
    > <allow users="Admin"/>
    > <deny users="*"/>
    > </authorization>
    > <authentication mode="Forms">
    > <forms
    > name="MyWebsiteCookieName"
    > loginUrl="LoginPage2.aspx"
    > protection="All"
    > timeout="180"
    > />
    > </authentication>
    > </system.web>
    > </location>
    > </configuration>
    >
    > But here I get this error:
    > It is an error to use a section registered as
    > allowDefinition='MachineToApplication' beyond application level.
    >
    > Many thanks for your help
    > Simon
    Stuart A Hill, Jan 19, 2005
    #2
    1. Advertising

  3. Hi Stuart

    Thank you for your swift answer. The issue is I would like to dedicate an
    seperate login page to each page. I can get it to work if I only use one
    login page outside the <location> element.

    What works:
    <configuration>
    <location path="Member" allowOverride="true">
    <system.web>
    <authorization>
    <!-- allow tags must be first -->
    <allow users="BØ"/>
    <allow users="SB"/>
    <deny users="*"/>
    </authorization>
    </system.web>
    </location>
    <system.web>
    <authentication mode="Forms">
    <forms
    name="MyWebsiteCookieName"
    loginUrl="Login.aspx"
    protection="All"
    timeout="180"
    />
    </authentication>
    </system.web>
    </configuration>

    What doesn't work:
    <configuration>
    <location path="Member" allowOverride="true">
    <system.web>
    <authorization>
    <!-- allow tags must be first -->
    <allow users="Admin"/>
    <allow users="User"/>
    <deny users="*"/>
    </authorization>
    <authentication mode="Forms">
    <forms
    name="MyWebsiteCookieName"
    loginUrl="LoginPage1.aspx"
    protection="All"
    timeout="180"
    />
    </authentication>
    </system.web>
    </location>
    </configuration>

    As you can see when the authentication is placed within the <location>
    element, everything goes nuts :).
    Best regards
    Simon


    "Stuart A Hill" wrote:

    > Hi Simon,
    >
    > This error would normally indicate that the Virtual Directory for your web
    > is not set up properly.
    >
    > 1. Go to Start - Settings - Control Panel - Administrative Tools - Internet
    > Information Services
    > 2. Expand the nodes to see Default Web Site
    >
    > Do you have node for your web site? If so check the properties or if you are
    > not sure about this delete it. If it is not there do the following:
    >
    > 3. Right-click the Default Web Site node to bring up the menu and select
    > New - Virtual Directory
    > 4. Create a new virtual directory and the location is the folder location of
    > your files..
    >
    > Try it again. If this isn't the problem and you still get the same error,
    > I'll look in more detail at your web.config entries.
    >
    > Regards,
    >
    > Stuart
    > MCSD, MCT
    >
    >
    > "SB" <> wrote in message
    > news:...
    > > Hi
    > > I'm trying to get forms-based authentication to authenticate different
    > > users
    > > for differet pages, like this:
    > >
    > > <configuration>
    > > <location path="Member" allowOverride="true">
    > > <system.web>
    > > <authorization>
    > > <!-- allow tags must be first -->
    > > <allow users="Admin"/>
    > > <allow users="User"/>
    > > <deny users="*"/>
    > > </authorization>
    > > <authentication mode="Forms">
    > > <forms
    > > name="MyWebsiteCookieName"
    > > loginUrl="LoginPage1.aspx"
    > > protection="All"
    > > timeout="180"
    > > />
    > > </authentication>
    > > </system.web>
    > > </location>
    > > <location path="Admin" allowOverride="true">
    > > <system.web>
    > > <authorization>
    > > <!-- allow tags must be first -->
    > > <allow users="Admin"/>
    > > <deny users="*"/>
    > > </authorization>
    > > <authentication mode="Forms">
    > > <forms
    > > name="MyWebsiteCookieName"
    > > loginUrl="LoginPage2.aspx"
    > > protection="All"
    > > timeout="180"
    > > />
    > > </authentication>
    > > </system.web>
    > > </location>
    > > </configuration>
    > >
    > > But here I get this error:
    > > It is an error to use a section registered as
    > > allowDefinition='MachineToApplication' beyond application level.
    > >
    > > Many thanks for your help
    > > Simon

    >
    >
    >
    =?Utf-8?B?U0I=?=, Jan 19, 2005
    #3
  4. I would do that by writing the different usergroups in the config file

    <allow users="Admins"/>
    <allow users="Users"/>

    And the when they log in give then the rights

    If Admin logs in Then
    System.Web.Security.FormsAuthentication.RedirectFromLoginPage("Admins",
    False)
    ElseIF User logs in Then
    System.Web.Security.FormsAuthentication.RedirectFromLoginPage("Users",
    False)
    End If


    /Simon


    "David Jessee" wrote:

    > can you take the approach of a single logon page and in the login, set the
    > users' Roles? then verify for different roles within the forms? instead of
    > adding users to each form's permission, you'd ass them to the groups.
    > Effectively its the mase hting, and its supported by the framework
    >
    >
    > "SB" <> wrote in message
    > news:...
    > > Hi
    > > I'm trying to get forms-based authentication to authenticate different

    > users
    > > for differet pages, like this:
    > >
    > > <configuration>
    > > <location path="Member" allowOverride="true">
    > > <system.web>
    > > <authorization>
    > > <!-- allow tags must be first -->
    > > <allow users="Admin"/>
    > > <allow users="User"/>
    > > <deny users="*"/>
    > > </authorization>
    > > <authentication mode="Forms">
    > > <forms
    > > name="MyWebsiteCookieName"
    > > loginUrl="LoginPage1.aspx"
    > > protection="All"
    > > timeout="180"
    > > />
    > > </authentication>
    > > </system.web>
    > > </location>
    > > <location path="Admin" allowOverride="true">
    > > <system.web>
    > > <authorization>
    > > <!-- allow tags must be first -->
    > > <allow users="Admin"/>
    > > <deny users="*"/>
    > > </authorization>
    > > <authentication mode="Forms">
    > > <forms
    > > name="MyWebsiteCookieName"
    > > loginUrl="LoginPage2.aspx"
    > > protection="All"
    > > timeout="180"
    > > />
    > > </authentication>
    > > </system.web>
    > > </location>
    > > </configuration>
    > >
    > > But here I get this error:
    > > It is an error to use a section registered as
    > > allowDefinition='MachineToApplication' beyond application level.
    > >
    > > Many thanks for your help
    > > Simon

    >
    >
    >
    =?Utf-8?B?U0I=?=, Jan 20, 2005
    #4
  5. =?Utf-8?B?U0I=?=

    David Jessee Guest

    can you take the approach of a single logon page and in the login, set the
    users' Roles? then verify for different roles within the forms? instead of
    adding users to each form's permission, you'd ass them to the groups.
    Effectively its the mase hting, and its supported by the framework


    "SB" <> wrote in message
    news:...
    > Hi
    > I'm trying to get forms-based authentication to authenticate different

    users
    > for differet pages, like this:
    >
    > <configuration>
    > <location path="Member" allowOverride="true">
    > <system.web>
    > <authorization>
    > <!-- allow tags must be first -->
    > <allow users="Admin"/>
    > <allow users="User"/>
    > <deny users="*"/>
    > </authorization>
    > <authentication mode="Forms">
    > <forms
    > name="MyWebsiteCookieName"
    > loginUrl="LoginPage1.aspx"
    > protection="All"
    > timeout="180"
    > />
    > </authentication>
    > </system.web>
    > </location>
    > <location path="Admin" allowOverride="true">
    > <system.web>
    > <authorization>
    > <!-- allow tags must be first -->
    > <allow users="Admin"/>
    > <deny users="*"/>
    > </authorization>
    > <authentication mode="Forms">
    > <forms
    > name="MyWebsiteCookieName"
    > loginUrl="LoginPage2.aspx"
    > protection="All"
    > timeout="180"
    > />
    > </authentication>
    > </system.web>
    > </location>
    > </configuration>
    >
    > But here I get this error:
    > It is an error to use a section registered as
    > allowDefinition='MachineToApplication' beyond application level.
    >
    > Many thanks for your help
    > Simon
    David Jessee, Jan 20, 2005
    #5
    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. Matthew Louden
    Replies:
    2
    Views:
    315
    Scott M.
    Nov 1, 2003
  2. Richard
    Replies:
    0
    Views:
    346
    Richard
    Sep 1, 2004
  3. xyZed
    Replies:
    7
    Views:
    540
    xyZed
    Apr 14, 2006
  4. Shannon

    login page stays on login page

    Shannon, Jan 9, 2008, in forum: ASP .Net
    Replies:
    2
    Views:
    536
    Shannon
    Jan 9, 2008
  5. Igor Nn
    Replies:
    7
    Views:
    435
    Johnny Morrice
    May 28, 2011
Loading...

Share This Page