Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Multiple Web.Config Files

Status
Not open for further replies.

henslecd

MIS
Apr 21, 2003
259
US
I have a site where I want to allow different groups access certain areas.

I have my main web.config, and a web.config in the subdirectory that I want to redirect to a login page.

This is my Main web.config

Code:
1<system.web>
2
3<authentication mode="Forms">
4  <forms name="yourAuthCookie"
5 loginUrl="administrator/adminlogin.aspx"
6    protection="All" path="/" />
7</authentication>
8
9<authorization>
10  <deny users="?" />
11</authorization>
12   
13 </system.web>
14  
15  <location path="Site">
16    <system.web>
17      <authorization>
18        <allow users="?" />
19      </authorization>
20    </system.web>
21  </location>

This works fine. It forces anyone wanting to go to an admin directory to the adminlogin.aspx page(line 5). If they want to go to the Site directory(line 15), they have full access without having to sign in.

However, I have a Members directory inside of Site. I dropped a web.config into the Members directory.

Code:
1  <system.web>
2
3<authorization>
4  <deny users="?" />
5  <allow users="*" />
6</authorization>
7
8  </system.web>

This works fine too, except it redirects to the adminlogin.aspx page instead of a memberslogin.aspx page. Where can I put code that will redirect anyone trying to access the members directory to memberslogin.aspx as opposed to adminlogin.aspx?

Thanks for the help.

Chad
 
AFAIK, the Authentication section is application-wide (i.e. you cannot specify one login page for one directory and a differnet one for another). For the specific location tags, you can only set the Authorization for that directory. So just one login page per application. (correct me if I'm wrong). What you could do is check the ReturnUrl from the login page and use that to determine if the user should be redirected to the administrator or members directory.

Since what you have is somewhat complicated, I would not use multiple web.configs - just do it all in the root web.config, using the location tags as you have done. Just to avoid confusion.

Greetings,
Dragonwell
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top