mylogin.aspx page
<%@ Page Language="C#" AutoEventWireup="true" CodeFile="mylogin.aspx.cs" Inherits="mylogin" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title></title>
</head>
<body>
<form id="form1" runat="server">
<div>
Enter the user name:
<asp:TextBox ID="txtusername" runat="server"></asp:TextBox>
<br />
<br />
Enter the password:
<asp:TextBox ID="txtpassword" runat="server"></asp:TextBox>
</div>
<asp:Button ID="Button1" runat="server" onclick="Button1_Click" Text="Login" />
</form>
</body>
</html>
----------------------------------------------------------------
mylogin.aspx.cs
protected void Page_Load(object sender, EventArgs e)
{
if (FormsAuthentication.Authenticate(txtusername.Text, txtpassword.Text))
FormsAuthentication.RedirectFromLoginPage(txtusername.Text, false);//login page display before running any page //becuase of false cookies not store
}
-------------------------------------------------------------------------
web.config code
<system.web>
<authentication mode="Forms">
<forms loginUrl="mylogin.aspx" name="abc">
<credentials passwordFormat="Clear">
<user name="john" password="jim" />
<user name="sunita" password="sim" />
</credentials>
</forms>
</authentication>
<authorization>
<allow users="sunita" />
<allow roles="hr"/>
<deny users="*" />
</authorization>
</system.web>
---------------------------------------------
<deny users="*" /> expect sunita all user denied