Logout User In Asp.net Membership
While developing usermanagement based web application using Membership provider, many times we come across some trivial issues or queries as follows
Above code signout the user, remove all the Cookies set.
Forms Authentication.RedirectToLoginPage uses settings in web.config file. We can pass Querystring to the function so that we can show proper Messages.
- formsauthentication.signout not working
- Using formsauthentication.signout
- logout user programmatically
- Check user date subscription and log out if user is not valid.
- programmatically logout in asp net
- Logout user in asp.net Membership
Solution for all above queries is as follows
FormsAuthentication.SignOut(); Session.Abandon(); // clear authentication cookie HttpCookie frmcookie = new HttpCookie(FormsAuthentication.FormsCookieName, ""); frmcookie.Expires = DateTime.Now.AddYears(-1); Response.Cookies.Add(frmcookie); // clear session cookie if we use any HttpCookie sessioncookie = new HttpCookie("ASP.NET_SessionId", ""); sessioncookie.Expires = DateTime.Now.AddYears(-1); Response.Cookies.Add(sessioncookie); FormsAuthentication.RedirectToLoginPage("v=SubscriptionExpired");
0 comments:
Post a Comment