FormsAuthentication.RedirectFromLoginPage (VB) : FormsAuthentication « Login Security « ASP.Net






FormsAuthentication.RedirectFromLoginPage (VB)


<%@ Page Language="VB" %>

<script runat="server">
    Protected Sub Button1_Click(ByVal sender As Object, _
      ByVal e As System.EventArgs)

        If FormsAuthentication.Authenticate(TextBox1.Text, TextBox2.Text) Then
            FormsAuthentication.RedirectFromLoginPage(TextBox1.Text, True)
        Else
            Response.Write("Invalid credentials")
        End If
    End Sub
</script>

<html xmlns="http://www.w3.org/1999/xhtml" >
<head id="Head1" runat="server">
    <title>Login Page</title>
</head>
<body>
    <form id="form1" runat="server">
    <div>
        Username<br />
        <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><br />
        <br />
        Password<br />
        <asp:TextBox ID="TextBox2" runat="server" 
         TextMode="Password"></asp:TextBox><br />
        <br />
        <asp:Button ID="Button1" OnClick="Button1_Click" runat="server" 
         Text="Submit" />
    </div>
    </form>
</body>
</html>


File: web.config

 
<system.web>
   <authentication mode="Forms">
      <forms name="form1" loginUrl="Login.aspx" path="/">
         <credentials passwordFormat="Clear">
            <user name="userName" password="Bubbles" />
         </credentials>
      </forms>
   </authentication>
   
   <authorization>
      <deny users="?" />
   </authorization>
</system.web>

 








Related examples in the same category

1.FormsAuthentication.Authenticate (C#)
2.Checking credentials in SQL Server (VB)
3.Checking credentials in SQL Server (C#)
4.assigning a name to the user accessing next pages
5.FormsAuthentication.SignOut()
6.Hash password
7.Save user account to an XML file