开发者

How to destroy a session of another than current user in asp.net

I'm开发者_JS百科 using asp.net 4.0 with asp.net MVC 2.0 and the asp.net membership provider.

I need to terminate a the user session before I delete it. Otherwise if the user is still authenticated the next time it will visit a page null reference exceptions will occur when trying to access the user data and profile.

I get the Session.Abandon() method but what I'm looking for is the same on a user, something like user.AbandonSessions().

I realize this question has been asked before but I can't get a straight answer.

Thanks


I think you may be tilting at windmills. There are just too many things working against your desired goal.

If you adjust your perspective to embrace the arbitrary nature of a browser based app and instead of trying to eradicate all vestiges of a users state in order to avoid errors, rather take measures to ensure that the required data is present in the session and if not then recreate it or redirect the user to an appropriate location.

In any case, remember that in order to affect any session related action capably, you must force a request cycle to ensure the cookies are properly processed by the browser, but that is beside the point I am trying to make.

Good luck.


You could use a custom membership provider which instead of deleting an account, just deactivates that. You could also have the custom membership provider to lock the account at the same time.


FormsAuthentication.SignOut();

But you need to call it in the context of the user you want to sign out.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜