suppose i have web app. where many user login and access few restricted content. i want admin will have power to kick out any user and as a result that user will not be able to access that restricted content of the page. in this scenario if admin can kill session of any particular user then it would be possible. so please tell in asp.net how i can forcefully kill other session when my session i开发者_运维技巧s different. how to design this type of web apps using web form technology. please advice.
thanks
You can't kill other Session.
What you can do is save in some global context (Application, Text file or Database) the list of all currently logged in users and enable the admin to add global "flag" for each that mark that user as "banned" then before showing restricted content, in addition to checking if user is logged in make sure he's not flagged.
Using Application level variable is the most simple way assuming you don't have thousands of users in the same time, you can add users in the Session_Start event in global.asax
and remove them in Session_End event. Store the users as ordinary List<string>
and have separate list holding the "flagged/banned" users.
Hope the logic is clear enough, let me know if you need help implementing it.
精彩评论