473,385 Members | 1,312 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,385 software developers and data experts.

protecting two different folders with forms authentication

I have an asp.net site for which I want to protect two different folders
(for arguments sake, call them "members" and "admin").

I'm reading username and password info from a database, which is working
fine. My problem is that I can't see how, using the web.config file, I can
specify which login page each folder uses.

Part of my web.config in the root looks like:

<authentication mode = "Forms" >
<forms loginUrl = "login.aspx"
name = ".ASPXAUTH"
protection="All"
timeout="10"
path="/"
/>

(with an <allow users="?" />).

And in both the /admin and /members directory, it looks like:

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

So when I try to access a aspx file in /admin, I get redirected to
/login.aspx. However, if I also want to protect the /members directory, how
do I configure it? At the moment, it's using the same session var
(.ASPXAUTH) for both types of login.

Currently, I also have a web.config in /members, but it looks the same as
the one in /admin, so when the user tries to access either the /members or
/admin directory they are redirected to /login.aspx. I want to members to
be redirected to members.login.aspx, and admin to redirect to
admin.login.aspx.

I hope that makes sense! I'm having problems explaining myself! :-)

TIA,
A.

Nov 19 '05 #1
2 1794
The <authorization?> settings in web.config affect all files and subfolders
by default wiht the same settings. If you want to change the settings fort
a specific file or directory you can use the <location> element:

<configuration>
<system.web></system.web>
<location path="SomeSubDir">
<system.web>
<authorization>
<allow roles="Admin" />
<deny users="*" />
<authorization>
</system.web>
</location>
</configuration>

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have an asp.net site for which I want to protect two different
folders (for arguments sake, call them "members" and "admin").

I'm reading username and password info from a database, which is
working fine. My problem is that I can't see how, using the
web.config file, I can specify which login page each folder uses.

Part of my web.config in the root looks like:

<authentication mode = "Forms" >
<forms loginUrl = "login.aspx"
name = ".ASPXAUTH"
protection="All"
timeout="10"
path="/"
/>
(with an <allow users="?" />).

And in both the /admin and /members directory, it looks like:

<authorization>
<deny users="?" />
</authorization>
So when I try to access a aspx file in /admin, I get redirected to
/login.aspx. However, if I also want to protect the /members
directory, how do I configure it? At the moment, it's using the same
session var (.ASPXAUTH) for both types of login.

Currently, I also have a web.config in /members, but it looks the same
as the one in /admin, so when the user tries to access either the
/members or /admin directory they are redirected to /login.aspx. I
want to members to be redirected to members.login.aspx, and admin to
redirect to admin.login.aspx.

I hope that makes sense! I'm having problems explaining myself! :-)

TIA,
A.


Nov 19 '05 #2
Excellent. Thanks Brock.

A.
"Brock Allen" <ba****@NOSPAMdevelop.com> wrote in message
news:27**********************@msnews.microsoft.com ...
The <authorization?> settings in web.config affect all files and
subfolders by default wiht the same settings. If you want to change the
settings fort a specific file or directory you can use the <location>
element:

<configuration>
<system.web></system.web>
<location path="SomeSubDir">
<system.web>
<authorization>
<allow roles="Admin" />
<deny users="*" />
<authorization>
</system.web>
</location>
</configuration>

-Brock
DevelopMentor
http://staff.develop.com/ballen
I have an asp.net site for which I want to protect two different
folders (for arguments sake, call them "members" and "admin").

I'm reading username and password info from a database, which is
working fine. My problem is that I can't see how, using the
web.config file, I can specify which login page each folder uses.

Part of my web.config in the root looks like:

<authentication mode = "Forms" >
<forms loginUrl = "login.aspx"
name = ".ASPXAUTH"
protection="All"
timeout="10"
path="/"
/>
(with an <allow users="?" />).

And in both the /admin and /members directory, it looks like:

<authorization>
<deny users="?" />
</authorization>
So when I try to access a aspx file in /admin, I get redirected to
/login.aspx. However, if I also want to protect the /members
directory, how do I configure it? At the moment, it's using the same
session var (.ASPXAUTH) for both types of login.

Currently, I also have a web.config in /members, but it looks the same
as the one in /admin, so when the user tries to access either the
/members or /admin directory they are redirected to /login.aspx. I
want to members to be redirected to members.login.aspx, and admin to
redirect to admin.login.aspx.

I hope that makes sense! I'm having problems explaining myself! :-)

TIA,
A.


Nov 19 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: Maziar Aflatoun | last post by:
Hi, I'm trying to protect one of my subfolders from Web.config file in my root folder. Here is my directory structure / // My shopping cart /admin // Shopping cart...
7
by: Shawn | last post by:
Hi. I have a folder that contains a lot of different documents. xls, .doc, .pdf etc. Different users have access to different documents. The problem is that if a user knows the name of a...
0
by: Jurjen de Groot | last post by:
I have build an ASP.NET application and would like to protect various folders containing aspnet pages for various usertypes. /Admin /Manager /User I've created a login on the default.aspx in...
3
by: Mike Kingscott | last post by:
Hi there, I'm writing an app in which a punter buys some PDFs online. After purchasing said PDFs, they will be given a token (bless them Guids) to go to a download .ASPX page from which they can...
1
by: Maziar Aflatoun | last post by:
Hi everyone, I have a website that requires 2 separate sections to be password protected (/admin and /admin2) so that for ex. once the user in /admin2 is authenticated he/she can then view...
0
by: tshad | last post by:
How would I protect all my files from someone getting access to my asp,htm,gif,jpg etc. files? I can protect my .aspx files using Forms Authentication and dropping the following in my specific...
1
by: darrel | last post by:
I need to be able to password protect individual pages. For instance: /protected.aspx?id=123 /protected.aspx?id=555 Both would need to be only accessible to two different people (with their...
4
by: Phil Hellmuth | last post by:
Pardon my ignorance...I'm new to .NET...but I want a user to be forced to submit login credentials before displaying a page. Is there a quick, easy way to do this? Don't worry about verifying the...
5
by: drasko | last post by:
Hi, I have the following structure of my web-site root | -folder1 (secure) | -folder2 (secure) Now, as you can see, both folders are secure and need to have
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.