Hi,
how would I call the logout function in the code behind file if the user navigates away from the page by typing some url in the address field of the web browser.
I am using ASP.net C#
thanks in advance for all replies
>>how would I call the logout function in the code behind file if the user navigates away from the page by typing some url in the address field of the web browser.
u have to use the "OnUnLoad" event of the body tag.
this must open a popup that will call an ASPX file that will kill the session. i dont see any other approach!!!
You can set a time limit in the web.config, timeout = 20 (default value in minutes). After that time your session will be destroyed. It is like automatic logoff
Dear vbkris
your solution works. just some followup questions:
1. I tried but i don't think the OnUnLoad property of body tag work with MACs. It worked on PC
2. In the javascript I have this line:
window.location="logout.aspx"
basically when body unloads, it goes to logout.aspx
is it possible to extract the url that the user typed in so that i can forward it to the logout.aspx page so that after the logout.aspx page loges them out it will then automatically redirect them to the page they wanted to go.
examplbe logout.aspx?forward=
>> I tried but i don't think the OnUnLoad property of body tag work with MACs. It worked on PC
No go there. its javascript which unlike .NET is system specific.
>>is it possible to extract the url that the user typed in so that i can forward it to the logout.aspx page so that after the logout.aspx page loges them out it will then automatically redirect them to the page they wanted to go.
examplbe logout.aspx
no i dont think so, however u could try:
use this in ur popup
<script>
alert(opener.location.href)
</script>
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.