Click to See Complete Forum and Search --> : Creating my own Login system in ASP.NET 2.0


SuPerNoVi
10-18-2006, 08:51 AM
Hey, basically I already have a system built using normal ASP. This means I already have a database full of information for customers.

This means I do not want to use the default login system you can make using Visual Web Developer Express, I can easily create a login system but I am looking to create my own using my exsisting database.

Is this possible? has anyone here got a solution?

All help is greatly appreciate :)

NoVi

sirpelidor
10-18-2006, 12:17 PM
it will be way easier for you to write your own code in order to authenicate against your existing database for login process.

I recommand only use the login control with you don't already have a database in place.

Cstick
10-18-2006, 06:53 PM
If I were in your position, then I'd use forms authentication and use your existing database to authenticate users against.

Microsoft built the functionality into ASP.Net, why not use it? If you google "Forms authentication", then you'll get all you need to get moving with it, including examples for authenticating against custom datasources.

BTW, this extends sirpelidor's suggestion, you'll write your own authencation method that you'll use with forms authentication.

SuPerNoVi
10-19-2006, 06:45 AM
Right okay well I have been trying to do the whole forms idea but I keep hitting dead ends.

I have managed to get a form authentication working with the password and username in the Web.config file but I can't get it to look at a SQL database and match the data up there. I have looked at a few tutorials but they don't make much sense.

Can anyone point me towards a good "beginner" tutorial to help me through this.

Thanks for the replies so far.

sirpelidor
10-19-2006, 11:37 AM
at web.config, normally wanna alter 2 xml tags: authentication, authorization.

here's a sample example (again, just like cstick said, this examples are everywhere on google....)
step 1: google "authenication web.config"

<authentication mode="Forms">
<forms name="myWebPageCookie"
loginUrl="login.aspx"
timeout="30">
</forms>
</authentication>


step 2: google "authorization web.config"

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


now, at your aspx.vb or aspx.cs code behind...you'll have write your own sql statment, authenicate against database and to decided if user is authenicated or not. I'll omit sql here as I assume you know what you are doing...

step 3: google "FormsAuthentication.RedirectFromLoginPage"

//bool isVerify and string userID will be come from sql result
if (isVerify){
FormsAuthentication.RedirectFromLoginPage(userID, false);
Response.Redirect("myauthenicatedPage.aspx");
}
else{
//login fail, redirect'em sign up or whatever...
}