Session Timeout Question

S

Stephen Noronha

Hi,

I am creating a test applicaiton with 3 pages say login.aspx test1.aspx and
test2.aspx.
I added this to my global.asax file

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
' Fires when the session ends
Session.Timeout = 1
Response.redirect("Login.aspx")
End Sub

question:
1. do I have to change the timeout value in web.config file also?
2. I browsed to test2.aspx and then waited for session to time out, but the
page was not redirected to "Login.aspx"...... why?
i even had a break point, it fired but did nothing.

Please advice,
Stephen
 
J

Jack Li

Hi Stephen,

Answer:
1. You can set it on web.config, but the meaning is not the same. Setting
the Session.Timeout is per request only while web.config is per the web
application.
2. You cannot do response.redirect on Session_End, since the response is
already served.

If you want to redirect to login.aspx after one second, you may want use:
<meta http-equiv="refresh" content="1;url=login.aspx">

or using javascript by timeout.

Regards,
Jack Li
MVP (ASP.NET)
 
S

Stephen Noronha

Thanks Jack
Stephen

Jack Li said:
Hi Stephen,

Answer:
1. You can set it on web.config, but the meaning is not the same. Setting
the Session.Timeout is per request only while web.config is per the web
application.
2. You cannot do response.redirect on Session_End, since the response is
already served.

If you want to redirect to login.aspx after one second, you may want use:
<meta http-equiv="refresh" content="1;url=login.aspx">

or using javascript by timeout.

Regards,
Jack Li
MVP (ASP.NET)
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
473,969
Messages
2,570,161
Members
46,708
Latest member
SherleneF1

Latest Threads

Top