Hi guys
Ok, I have a website which has an "Artists Only" section, for which you have
to login for. This section is contained within its own directory on the
server "/aonly".
I want to make people login before they can access this directory, with a
User control on each page for logging in. I'd like to use Forms auth and sql
server (i know how to check that against the entered details).
I also want a login.aspx page so that if their session expires, it's easy to
log back in.
Question is.. how do I create the forms auth and make it protect the
"/aonly" directory, and can I make the user control authenticate the user,
and then forward to the protected directory?
HOpe that makes sense!
Cheers
Dan 4 1293
You should enable forms authentication in your root web.config (root of you
application, that is). For the subdirectory, you should then set the authorization
to not allow anonymous users. I presume the rest of the site is accessible
to anonymous users?
Here are the docs for configuring forms authentication: http://msdn.microsoft.com/library/de...gngrfforms.asp
And here's how you'd set the authorization: http://msdn.microsoft.com/library/de...asp?frame=true
Now since you're looking to control authorization on a subdirectory, the
authorization could go into an independant web.config in the child directory
you want to contol access to.
-Brock
DevelopMentor http://staff.develop.com/ballen Hi guys
Ok, I have a website which has an "Artists Only" section, for which you have to login for. This section is contained within its own directory on the server "/aonly".
I want to make people login before they can access this directory, with a User control on each page for logging in. I'd like to use Forms auth and sql server (i know how to check that against the entered details).
I also want a login.aspx page so that if their session expires, it's easy to log back in.
Question is.. how do I create the forms auth and make it protect the "/aonly" directory, and can I make the user control authenticate the user, and then forward to the protected directory?
HOpe that makes sense!
Cheers
Dan
Thanks Brock,
That seems to have got all the security stuff setup. I'm assuming I put the
code to authenticate against SQL in a function called by the clicking of my
signup button, is that right?
In which case, when I've authenticated a user, what do I need to set in
order for Forms authentication to let them in?
Cheers
Dan
"Brock Allen" wrote: You should enable forms authentication in your root web.config (root of you application, that is). For the subdirectory, you should then set the authorization to not allow anonymous users. I presume the rest of the site is accessible to anonymous users?
Here are the docs for configuring forms authentication:
http://msdn.microsoft.com/library/de...gngrfforms.asp
And here's how you'd set the authorization:
http://msdn.microsoft.com/library/de...asp?frame=true
Now since you're looking to control authorization on a subdirectory, the authorization could go into an independant web.config in the child directory you want to contol access to.
-Brock DevelopMentor http://staff.develop.com/ballen Hi guys
Ok, I have a website which has an "Artists Only" section, for which you have to login for. This section is contained within its own directory on the server "/aonly".
I want to make people login before they can access this directory, with a User control on each page for logging in. I'd like to use Forms auth and sql server (i know how to check that against the entered details).
I also want a login.aspx page so that if their session expires, it's easy to log back in.
Question is.. how do I create the forms auth and make it protect the "/aonly" directory, and can I make the user control authenticate the user, and then forward to the protected directory?
HOpe that makes sense!
Cheers
Dan
You want to do something like this
public void Login_Click(Object sender, EventArgs E)
{
_UserName = UserName.Value;
_Password = UserPass.Value;
if (CheckUserAndPassword (_ServerName, _DatabaseName,_UserName
,_Password))
{
System.Web.Security.FormsAuthentication.RedirectFr omLoginPage(UserName.Value,false);
}
else
{
Msg.Text = "Invalid Credentials: Please try again";
}
}
which puts them back to the originally requested URL.
Kirsty
> That seems to have got all the security stuff setup. I'm assuming I put the code to authenticate against SQL in a function called by the clicking of my signup button, is that right?
Right - you'll have to write the code to do the actual authentication against
your database of usernames/passwords.
In which case, when I've authenticated a user, what do I need to set in order for Forms authentication to let them in?
So once you know the user has provided valid credntials, you use FormsAuthentication.RedirectFromLoginPage("TheirUs ername",
false) or FormsAuthentication.SetAuthCookie to tell ASP.NET that they're
logged in.
-Brock
DevelopMentor http://staff.develop.com/ballen This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: tascien |
last post by:
I an application that i want to set up for two clients.
http://localhost/client1 <- virtual directory.
http://localhost/client2 <- virtual directory.
Now, i don't want these application to...
|
by: Justin |
last post by:
I am trying to password protect a subdirectory using forms authentication. I
am using the "Location" tag to specify the directory to be protected. The
login.aspx page is in the root directory of...
|
by: tascien |
last post by:
I an application that i want to set up for two clients.
http://localhost/client1 <- virtual directory.
http://localhost/client2 <- virtual directory.
Now, i don't want these application to...
|
by: Smokey Grindle |
last post by:
I am using forms authentication with a custom user database... I was
wondering, when logging in using forms auth, does the
HttpContext.Current.User return the forms logged in user or the AD user...
|
by: Rina0 |
last post by:
Cybersecurity engineering is a specialized field that focuses on the design, development, and implementation of systems, processes, and technologies that protect against cyber threats and...
|
by: isladogs |
last post by:
The next Access Europe meeting will be on Wednesday 2 August 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM)
The start time is equivalent to 19:00 (7PM) in Central...
|
by: erikbower65 |
last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps:
1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal.
2. Connect to...
|
by: kcodez |
last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
|
by: Taofi |
last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same
This are my field names
ID, Budgeted, Actual, Status and Differences
...
|
by: Rina0 |
last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
|
by: DJRhino |
last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer)
If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _
310030356 Or 310030359 Or 310030362 Or...
|
by: lllomh |
last post by:
Define the method first
this.state = {
buttonBackgroundColor: 'green',
isBlinking: false, // A new status is added to identify whether the button is blinking or not
}
autoStart=()=>{
|
by: Mushico |
last post by:
How to calculate date of retirement from date of birth
| |