Take the 2-minute tour ×
Stack Overflow is a question and answer site for professional and enthusiast programmers. It's 100% free, no registration required.

How can I make my Context.User.Identity.Name equal to empty string after the user log-out. Because every time I go to Login Page the Context.User.Identity.Name is not empty. Thus, redirecting the user to the default page even though he already logged in.

My Log-Out code contains the following that I've researched but still doesn't make the Context.User.Identity.Name empty:

Session.Abandon();
HttpContext.Current.User =
 new GenericPrincipal(new GenericIdentity(string.Empty), null);
FormsAuthentication.SignOut();
Response.Cookies[FormsAuthentication.FormsCookieName].Expires = DateTime.Now.AddYears(-1);`

While my login code contains:

if (Context.User.Identity.IsAuthenticated)
{
   Response.Redirect("~/Default.aspx", false);
}
share|improve this question
    
This has nothing to do with class-asp. Remove classic-asp tag and add ASP.NET. –  BabyDuck Mar 13 at 6:33

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.