end user's session on login

Posted by Jopito under ASP.NET on 2/19/2014 | Points: 10 | Views : 1309 | Status : [Member] | Replies : 1
I am having a problem ending a session in my application.When i click an email link,its supposed to take me to complete registration page.However,lets say user "A" is currently logged in,and here comes again "User B" who has been redirected to the page complete registration,that "User B" will not be able to get into registration page if "User A" is still logged in.He(i.e "User B") will see the window for "User B" but he cannot do tasks their.The application wont allow you to complete registration if someone is logged in but if no one is logged in,one is able to complete registration.How can i overcome this?
Have used session .abandon but not helping at all.Thanks

Mark as answer if satisfied


Responses

Posted by: Deepthijk on: 3/5/2014 [Member] Starter | Points: 25

Up
0
Down
Hi,

Please try this.
It works for me.


Add this javascript on the aspx page

<script language="javascript" type="text/javascript">
window.onbeforeunload =function HandleClose()
{
alert("Killing the session on the server!!");
PageMethods.AbandonSession();
}</script>


Code behind
[WebMethod]
public static void AbandonSession()
{
HttpContext.Current.Session.Abandon();
}






Jopito, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response