Forms Authentication and Authorization Anonymous User297420-Sep-2011How to use Forms Authentication and Authorization in ASP.NET?asp.netasp.net Updated on 20-Sep-2011
Anonymous User
20-Sep-2011Chris Anderson
20-Sep-2011In order to acheive your result first you have to write the some code in web.config file:
<system.web>
<authentication mode="Forms">
<forms loginUrl="login.aspx" defaultUrl="Employee.aspx" />
</authentication>
<authorization>
<allow users="aaa"/>
<allow users="bbb"/>
<deny users="*"/>
</authorization>
</system.web>
Then you have to authenticate and authorized the user based on the user available in authorization part:
string strId = Login1.UserName;
string strPass = Login1.Password;
if (strId == "aaa" && strPass == "aaa")
FormsAuthentication.RedirectFromLoginPage(strId, false);
else
Login1.FailureText = "Invalid ID or Password";
Thanks.