~ Simple login application ~
Web.config
<system.web>
<authentication mode=”Forms”>
<forms loginUrl=”~/ Login.aspx” timeout=”2880″/>
</authentication>
</system.web>
Login.aspx
<asp:Label ID=”UserNameLabel” runat=”server” AssociatedControlID=”UserName”>User Name:</asp:Label>
<asp:TextBox ID=”UserName” runat=”server”></asp:TextBox>
<asp:RequiredFieldValidator ID=”UserNameRequired” runat=”server”
ControlToValidate=”UserName” ErrorMessage=”User Name is required.”
ToolTip=”User Name is required.” ValidationGroup=”Login1″>*
</asp:RequiredFieldValidator><asp:Label ID=”PasswordLabel” runat=”server” AssociatedControlID=”Password”>Password:</asp:Label>
<asp:TextBox ID=”Password” runat=”server” TextMode=”Password”></asp:TextBox>
<asp:RequiredFieldValidator ID=”PasswordRequired” runat=”server”
ControlToValidate=”Password” ErrorMessage=”Password is required.”
ToolTip=”Password is required.” ValidationGroup=”Login1″>*</asp:RequiredFieldValidator><asp:Literal ID=”FailureText” runat=”server” EnableViewState=”False”></asp:Literal>
<asp:Button ID=”LoginButton” runat=”server” CommandName=”Login” Text=”Log In” ValidationGroup=”Login1″ />
Login.aspx.vb
Partial Class Login
Inherits System.Web.UI.PageFunction SiteSpecificAuthenticationMethod(ByVal UserName As String, ByVal Password As String) As Boolean
‘ Insert code that implements a site-specific custom
‘ authentication method here.
If UserName = “YourUsn” And Password = “YourPwd” Then
Response.Redirect(“YourPage.aspx”)
End If
‘ This example implementation always returns false.
Return False
End FunctionSub OnAuthenticate(ByVal sender As Object, ByVal e As AuthenticateEventArgs)
Dim Authenticated As Boolean
Authenticated = SiteSpecificAuthenticationMethod(Login1.UserName, Login1.Password)e.Authenticated = Authenticated
End SubEnd Class