Documentation

Security / AspNetAuthenticator

This authenticator will use the built in API in .NET you can read more about .NET forms authentication at the MSDN website.

Simple example of Forms Authentication

Using the built in AspNetAuthenticator allows you to login using passwords defined in Web.Config or using Active Directory etc. We won't cover all that since the Microsoft documentation covers that. This simple example uses form authentication.

Change the authenticator option to "AspNetAuthenticator" in Web.Config:
<add key="authenticator" value="AspNetAuthenticator" />
Add this into your Web.Config to enable AspNet Forms authentication:
<system.web>
<authentication mode="Forms">
<forms name="MoxieManager" loginUrl="~/AspNetLogin.aspx">
<!-- Use SHA1, Clear is just used to make the example simpler -->
<credentials passwordFormat="Clear" >
<user name="user" password="pass" />
</credentials>
</forms>
</authentication>
</system.web>
Create a new login page AspNetLogin.aspx with this code:
<%@ Page Language="C#" %>
<%@ Import Namespace="System.Web.Security" %>
<script runat="server">
void Logon_Click(object sender, EventArgs e) {
if (FormsAuthentication.Authenticate(Username.Text, Password.Text)) {
FormsAuthentication.RedirectFromLoginPage(Username.Text, true);
} else {
Msg.Text = "Invalid credentials. Please try again.";
}
}
</script>
<html>
<body>
<form id="login" runat="server">
<asp:TextBox ID="Username" runat="server" />
<asp:TextBox ID="Password" TextMode="Password" runat="server" />
<asp:Button ID="Submit1" OnClick="Logon_Click" Text="Login" runat="server" />
<asp:Label ID="Msg" ForeColor="red" runat="server" />
</form>
</body>
</html>

You can now login using the username "user" and password "pass" by using that on the AspNetLogin.aspx page in your browser.