ASP.NET Security and Authentication.

Add following in web.config File


               <authentication mode="Forms">
      <forms name="f" defaultUrl="default.aspx" loginUrl = "login.aspx" path="/" protection="All">
        <credentials passwordFormat="Clear" >
          <user name="vin" password="1"/>
          <user name="pinx" password="123"/>
          
        </credentials>
      
      </forms>
    </authentication>
    
    <authorization>
      <allow users="vin"/>
      <deny users="pinx"/>
    </authorization>




have 2 page default.aspx and login.aspx
In login.aspt have 2 textbox and 1 button. vb code is:


Protected Sub Button1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles Button1.Click
        If FormsAuthentication.Authenticate(TextBox1.Text, TextBox2.Text) Then
            FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, False)
        Else
            Response.Write("Invalid User")
        End If

    End Sub

Comments