The below code and the config works fine, but force to enter user name/password case sensitively, i want to make it non case sensitive.
Code:
protected void LoginButton_Click(object sender, EventArgs e)
{
try
{
string uid = UserText.Text.Trim();
string pwd= PwdText.Text.Trim();
if (string.IsNullOrEmpty(uid) ||
string.IsNullOrEmpty(pwd))
{
throw new ApplicationException("UserName or Password should not be blank.");
}
bool isAuthrnticated = FormsAuthentication.Authenticate(uid, pwd);
if (isAuthrnticated)
{
FormsAuthentication.SetAuthCookie("Admin", false);
//...
}
else
{
((Site)this.Master).ShowError("Invalid UserName/Password.", ErrorSeverity.Warning);
}
}
catch (Exception ex)
{
ErrorLogger.LogError(ex);
((Site)this.Master).ShowError(ex.Message, ErrorSeverity.Warning);
}
}
Web.Config
<authentication mode="Forms">
<forms defaultUrl="~/Default.aspx" loginUrl="~/Default.aspx" slidingExpiration="true" timeout="1000">
<credentials passwordFormat="Clear">
<user name="Admin" password="ZAdmin"/>
</credentials>
</forms>
</authentication>