Welcome!

And don't forget to edit your signature & profile.

 

Icon

Statistics

  • Total posts 23319
  • Total topics 4049
  • Total members 5574
  • Our newest member
    ALF5583

TOP POSTERS

User login with C# and ASP.NET

All problems and developments related to PHP, Ruby on Rails & Co. are discussed and resolved here.
   

User login with C# and ASP.NET

Postby Jova » Mon Oct 05, 2009 4:25 am

Anyone here using C# and ASP.NET?

I could use a little help on making a secure user register and login to a website.

How would I go about doing this the best way? I could make a simple save to database of the username and password, and then check against that but that's not very secure or protected.
Jova
Smashing <table>
 
Posts: 24
Joined: Thu Oct 01, 2009 12:31 pm
Location: Sweden
   

   

Re: User login with C# and ASP.NET

Postby Andy » Mon Oct 05, 2009 5:24 am

1. Encrypt the password using SHA-1 before placing it in the database. Whenever checking a login, sha1 encrypt the submitted password and compare with the one in the database.
2. Use prepared statements whenever dealing with external data in your SQL queries.
3. Use a session to refer to the user account.
Andy
Smashing <h5>
 
Posts: 1023
Joined: Tue Sep 30, 2008 6:42 pm
Location: Sweden
   

   

Re: User login with C# and ASP.NET

Postby mike360 » Thu Oct 15, 2009 12:00 pm

The .NET framework has a collection of classes for user registration, login and session management. Check out this article on Membership, MembershipUser, Roles and Profiles (linked below). There's also (if I recall correctly) a Registration Wizard control that you can use. The whole package covers a lot more than what you need from the sounds of it but it's worth while to look at.

http://www.4guysfromrolla.com/articles/120705-1.aspx

Also, refer to the System.Web.Security namespace on MSDN which contains all the documentation for the classes you need.

http://msdn.microsoft.com/en-us/library ... urity.aspx

It has been over a year since I've written any Asp.NET stuff and even longer since using these classes but I do recall them being pretty helpful.
User avatar
mike360
Smashing <frame>
 
Posts: 15
Joined: Mon Feb 09, 2009 5:16 pm
   

   

Re: User login with C# and ASP.NET

Postby Jova » Thu Oct 15, 2009 12:11 pm

Thanks. :)

I've already done the tutorial over at www.asp.net which goes through the same things but I'll look into these links as well. :)
Jova
Smashing <table>
 
Posts: 24
Joined: Thu Oct 01, 2009 12:31 pm
Location: Sweden
   


Return to Server-side Scripting



Who is online

Users browsing this forum: No registered users and 1 guest