.NET Tutorials, Forums, Interview Questions And Answers
Welcome :Guest
 
Sign In
Register
 
Win Surprise Gifts!!!
Congratulations!!!


Top 5 Contributors of the Month
david stephan

Home >> Code Snippets >> ADO.NET >> Post New Resource Bookmark and Share   

 Subscribe to Code Snippets

Form Authentication in asp.net

Posted By:varun bansal       Posted Date: July 27, 2009    Points: 10    Category: ADO.NET    URL: http://www.dotnetspark.com  
 

Using Form Authentication, u can protect your web application from unauthorized access..
only valid user can acces your application after valid login..

This code shows how to implement form authentication in asp.net


















in web config file;

<authentication mode="Forms" >

  <forms name="logon" path="/" loginUrl="~/logon.aspx" protection="All" timeout="75"/>

  </authentication >

  <authorization>

    <deny users="?"/>

  </authorization>
in logon.aspx file;

protected void Button1_Click(object sender, EventArgs e)

  {

     if (TextBox1.Text == "varun" && TextBox2.Text == "v")

     {            

      FormsAuthentication.RedirectFromLoginPage(TextBox1.Text,

      CheckBox1.Checked);     

  }
in signout button;
FormsAuthentication.SignOut();

Response.Redirect("logon.aspx");

Regards
Varun bansal
www.varunbansal007.blogspot.com

     

Further Readings:

Responses

No response found. Be the first to respond this post

Post Comment

You must Sign In To post reply
Find More code samples in C#, ASP.Net, Vb.Net and more Here

Hall of Fame    Twitter   Terms of Service    Privacy Policy    Contact Us    Archives   Tell A Friend