c# - Unable to logout from ASP.NET MVC application using FormsAuthentication.SignOut() -


i trying implement logout functionality in asp.net mvc.

i use forms authentication project.

this logout code:

formsauthentication.signout(); response.cookies.clear(); formsauthenticationticket ticket =      new formsauthenticationticket(         1,         formsauthentication.formscookiename,         datetime.today.addyears(-1),         datetime.today.addyears(-2),         true,         string.empty);  response.cookies[formsauthentication.formscookiename].value =              formsauthentication.encrypt(ticket);  response.cookies[formsauthentication.formscookiename].expires =              datetime.today.addyears(-2);  return redirect("logon"); 

this code redirects user login screen. however, if call action method specifying name in address bar (or select previous link address bar dropdown), still able reach secure pages without logging in.

could me solve issue?

that's strange... make 1 single call to: formsauthentication.signout(); , works...

public actionresult logout() {   formsauthentication.signout();   return redirect("~/"); } 

Comments

Popular posts from this blog

ASP.NET/SQL find the element ID and update database -

jquery - appear modal windows bottom -

c++ - Compiling static TagLib 1.6.3 libraries for Windows -