Different login page for each document...

G

Guest

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
 
S

Stuart A Hill

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
 
G

Guest

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
 
G

Guest

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
 
D

David Jessee

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top