This is an offshoot of this question.
Login control if I don't have a MembershipProvider to point it at? Login control without a MembershipProvider? MembershipProvider do more than just username/password checking?MembershipProvider with the same authentication logic?In my case, I don't need a MembershipProvider (I think) as my authentication situation is trivial (one user, one password).
I'm interested partly to "future proof" my page and partly because I'm new and wondering about how stuff works. (I tend to learn about things by running full speed into every corner case I can find :)
You can just drop the asp:Login control in your page, then in the code behind, catch the Login Control's Authenticate event.
In the Authenticate event, check the username/password that the user has entered. The username/password are properties in the login control. (LoginCtrl.UserName, LoginCtrl.Password)
If the username/password is correct, just set the event args Authenticated property to True.
No membership provider is required.
ex. In the aspx page..
<asp:Login ID="LoginCtrl" runat="server" DestinationPageUrl="YouAreIn.aspx"></asp:Login>
In Code Behind
Private Sub Log_Authenticate(ByVal sender As Object, ByVal e As System.Web.UI.WebControls.AuthenticateEventArgs) Handles LoginCtrl.Authenticate
If LoginCtrl.UserName = "Hello" AndAlso LoginCtrl.Password = "Hello" Then
e.Authenticated = True
End If
c#
void MyLogin_Authenticate(object sender, AuthenticateEventArgs e)
{
if(UserName == "Hello" && Password == "Hello")
e.Authenticated = true;
}
If you don't have a membership provider and don't really have a security system to speak of, just put two boxes on a form (user name, password) and test it in the onclick of the button.
The login control is obviously overkill for what your trying to do.
Use Simple Forms Authentication.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With