I am trying to make Login through webConfig but it is not working. When I click on Login with the user and pass it is not redirected to theAllowUsers page. Please advice. THank you.
WebConfig
<authentication mode="Forms">
<forms loginUrl="~/RestrictedArea/Login.aspx" defaultUrl="~/AllowUsers.aspx" timeout="2880">
<credentials passwordFormat="Clear">
<user name="jack" password="jack123" />
<user name="jill" password="jill123" />
</credentials>
</forms>
<location path="~/AllowUsers.aspx">
<system.web>
<authorization>
<allow users="jack" />
<allow users="jill" />
<deny users="*" />
</authorization>
</system.web>
</location>
RestrictedArea/Login page:
<asp:Login ID="Login1" runat="server" OnAuthenticate="Login1_Authenticate">
</asp:Login>
RestrictedArea/Login page codeBehind:
protected void Login1_Authenticate(object sender, AuthenticateEventArgs e)
{
string username = Login1.UserName;
string password = Login1.Password;
if (FormsAuthentication.Authenticate(username, password))
{
FormsAuthentication.RedirectFromLoginPage(username, false);
Response.Redirect("AllowUsers.aspx");
}
}
AllowUsers page codeBehind:
protected void Button1_Click(object sender, EventArgs e)
{
FormsAuthentication.SignOut();
Response.Redirect("~/RestrictedArea/Login.aspx");
}