Exforsys.com
 

Sponsored Links

 

ASP.NET Tutorials

 
Home Tutorials ASP.NET
 

Securing ASP.NET Applications with C#

 

Securing ASP.NET Applications with C# - Page 3

Page 3 of 3


Signing out a user Securely


You have seen the sign out button on the Internet on various websites. The website "www.codersource.net also have the feature to signout users when they are done browsing. Let's see how we can implement a simple signout method. The logic behing the sign out is to expire the user cookie.


FormsAuthentication.SignOut();

Client side Validation

Don't leave all the things for your business logic and then for the database to decide. Do all the validation before you send the data to the business layers and the database layers. For this you can always use RequiredFieldValidators to check that if the required fields are not left blank.

I hope you enjoyed the tutorial happy programming !


 



Response.Cookies["UserName"].Value = null;


// The date can be anything which has already passed


Response.Cookies["UserName"].Expires = new System.DateTime(1999,10,12);


Response.Redirect("Whateverpage.aspx");


As you can see the code above is pretty simple and straight forward. The FormsAuthentication class provides a signout method which can be used to signout users.

Later we assign null to the cookie and expired the cookies date by assigning it a date which has already passed. After signout the user I simply redirected the user to another page.



{


FormsAuthentication.RedirectFromLoginPage(txtUserName.Text,false);





By default it is set to the Windows authentication mode in order to change this to forms authentication you will just need to change the windows to forms as I have shown below:

< authentication mode="Forms" / >

Okay so now you have set your application to use the features of the forms authentication instead of the windows authentication.




First Page: Securing ASP.NET Applications with C#


Read Next: ASP.NET with C# Training Launch

 

 

Comments


ASPChamp said:

  Hi all, I\'m new here. Hope to ctach up with the project work.
June 9, 2005, 7:25 pm

Harish said:

  Its was very simple and really good!
June 13, 2006, 11:59 am

Jatinsahotra said:

  I think this tutorial is very helpful for the begginers, and you can easily know the basic of .Net here.. Really cool
January 18, 2007, 7:28 am

darshan thacker said:

  i dont know how to get custom authentication coding out plz if u know than help me out
April 13, 2007, 9:44 am

darshan thacker@gmail.com said:

  i had tried to do forms authentication for number of users but how to do with this can u give me some idea

thanks in advance

April 13, 2007, 9:46 am

thanks in advance said:

  tried to do forms authentication for number of users but how to do with this can u give me some idea



January 12, 2009, 8:02 am

Post Your Comment:

Members Please Login
Your Name:*
e-mail ID:(required for notification)*
Image Verification: 
 
 Subscribe    

Sponsored Links

 

Subscribe via RSS


Get Daily Updates via Subscribe to Exforsys Free Training via email


Get Latest Free Training Updates delivered directly to your Inbox...

Enter your email address:


 

Subscribe to Exforsys Free Training via RSS
 

 
Partners -  Privacy and Legal Policy -  Site News -  Contact   Sitemap  

Copyright © 2000 - 2009 exforsys.com. All Rights Reserved

Page copy protected against web site content infringement by Copyscape