Pankaj Mishra
Pankaj Mishra

Reputation: 20348

Forms Authentication for different roles?

I am developing a website in which I'm using forms authentication. We have 2 log in pages: one for user, another for admin.

I added this code into webconfig file for user.

<forms loginUrl="Login.aspx"  defaultUrl="Home.aspx" >

I am using this code for user side when user successfully logged in.

FormsAuthentication.RedirectFromLoginPage (UserName.Text, chkPersistCookie.Checked)

I am not using the default user membership database. I have my own database in SQL Server 2005.

I want same thing for admin, but the default url is Admin.aspx & login url is adminlogin.aspx for admin.

How can i assign in web config file for admin? Is it the right way to do that or any one have some better concept for that?

Upvotes: 6

Views: 269

Answers (2)

Pankaj Mishra
Pankaj Mishra

Reputation: 20348

I used This line of code and this worked for me.

FormsAuthentication.SetAuthCookie(txtUser.Text, true);
Response.Redirect("Admin.aspx");

Upvotes: 6

Musa Hafalir
Musa Hafalir

Reputation: 1770

Putting admin files to a folder and creating a web.config file in it, is an option. You can probably override the config rules there.

Upvotes: 0

Related Questions