log out asp.net user through sql?

2019-08-30 02:30发布

问题:

Can I force a log out through SQL for asp.net membership account?

回答1:

No record of currently logged in users are stored in Forms Authentication mode so it would be impossible to log out a user by some SQL execution alone.

Note that a data store like SQL is only used during the actual credential authentication step of the Forms Authentication lifetime:

Forms authentication control flow http://i.msdn.microsoft.com/Aa480476.formsauth(en-us,MSDN.10).gif

Forms Authentication generally utilizes client-side cookies to handle currently logged in users.

Source: Explained: Forms Authentication in ASP.NET 2.0



回答2:

For forms authentication you can use:

FormsAuthentication.SignOut();
FormsAuthentication.RedirectToLoginPage();

If you are trying to do this through Windows authentication see this.