how to implement logout for web apllication?
Hi all,
i am using form based authen. to secure my web application.But when i am trying to logout with FormsAuthentication.SignOut();and then Response.Redirect("../main/Login.aspx")but it gives "HTTP Error 404 - Not Found". My web.config as....
<authentication mode="Forms">
<forms loginUrl="Login.aspx"
name=".LOGINAUTH"
protection="All" timeout="30" path="/" slidingExpiration="true">
<credentials passwordFormat="Clear">
<user name="vishal" password="campus"/>
<user name="manas" password="manas"/>
</credentials>
</forms>
</authentication>
<machineKey validationKey="AutoGenerate" decryptionKey="AutoGenerate"/>
<authorization>
<allow users="*" />
<deny users="?"/>
</authorization>
And Login.aspx.cs as.....
if (FormsAuthentication.Authenticate(txtUserid.Text, txtPassword.Text))
{
FormsAuthentication.RedirectFromLoginPage(txtUseri d.Text, chkRemeberMe.Checked);
FormsAuthenticationTicket ticket = new FormsAuthenticationTicket(
1, this.txtUserid.Text, DateTime.Now,
DateTime.Now.AddMinutes(30), this.chkRemeberMe.Checked, "User");
string cookistr = FormsAuthentication.Encrypt(ticket);
HttpCookie hcookie = new HttpCookie(FormsAuthentication.FormsCookieName, cookistr);
if (this.chkRemeberMe.Checked)
{
hcookie.Expires = ticket.Expiration;
}
hcookie.Path = FormsAuthentication.FormsCookiePath;
Response.Cookies.Add(hcookie);
if (txtUserid.Text == "vishal")
{
Response.Redirect("../Adminstration.aspx");
}
else
{
Response.Redirect("../main/NotAuthorized.aspx");
}
}
so plz help me for that,,
Vish
|