Authentication Authorization ASP.Net Tutorial

File: Web.Config

  
    
      
        
          
          
          
        
      

    
  


<%@ Page Language="C#" %>
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    protected void btnLogin_Click(object sender, EventArgs e)
    {
        if (FormsAuthentication.Authenticate(txtUserName.Text,txtPassword.Text))
            FormsAuthentication.RedirectFromLoginPage(txtUserName.Text, chkRememberMe.Checked);
        else
            lblError.Text = "Invalid user name/password";
    }



    Forms Login


    
    

            id="lblError"
        EnableViewState="false"
        ForeColor="Red"
        Runat="server" />
    
            id="lblUserName"
        Text="User Name:"
        AssociatedControlID="txtUserName"
        Runat="server" />
    
            id="txtUserName"
        Runat="server" />
    
            id="lblPassword"
        Text="Password:"
        AssociatedControlID="txtPassword"
        Runat="server" />
    
            id="txtPassword"
        TextMode="Password"
        Runat="server" />
    
            id="chkRememberMe"
        Text="Remember Me"
        Runat="server" />
    
            id="btnLogin"
        Text="Login"
        OnClick="btnLogin_Click"
        Runat="server" />