Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

how to call the logout function in the code behind file if the user...

Status
Not open for further replies.

toptomato

Programmer
Jul 22, 2005
62
US
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!!!

Known is handfull, Unknown is worldfull
 
You can't.

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=
thanks alot
 
>> 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>

what do u get???

Known is handfull, Unknown is worldfull
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top