将会话超时页面重定向代码放在asp.net中的什么位置? [英] where to put session timeout page redirection code in asp.net?

查看:72
本文介绍了将会话超时页面重定向代码放在asp.net中的什么位置?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述


我需要在网站上查看会话超时.以下代码在我将这些代码放在子例程中的文件Global.asax.vb下时检测超时.
子Application_PreRequestHandlerExecute()
如果Session.IsNewSession = True,那么
Dim strCookieHEader As String = Request.Headers("Cookie")
如果不是strCookieHEader也不是,而且strCookieHEader.IndexOf("ASP.NET_SessionId")> = 0然后

''如果会话超时则重定向到索引页面
Response.Redirect("Index.aspx",True)
如果结束
如果结束
结束子


但是页面没有重定向到指定页面.代码中的问题是什么.

Hi,
I need to check session time out in website. The following code detecting the timeout when i''m put these code undert the file Global.asax.vb in the Subroutine

Sub Application_PreRequestHandlerExecute()
If Session.IsNewSession = True Then
Dim strCookieHEader As String = Request.Headers("Cookie")
If Not strCookieHEader Is Nothing AndAlso strCookieHEader.IndexOf("ASP.NET_SessionId") >= 0 Then

''Redirect to Index page if Session Time Out
Response.Redirect("Index.aspx", True)
End If
End If
End Sub


But the page is not redirecting to specified page. Whats the problem in the code. Is there any idea to use Some other Subroutine or Server.Transfer?

推荐答案

对此有不同的方法;

使用页面加载/回发检查或客户端计时器,请参见此页面以了解各种方法.

http://geekswithblogs.net/shahed/archive/2007/09/05/115173.aspx [^ ]
There are different approaches to this;

See this page for various methods, using both pageload/post back checks or client side timers.

http://geekswithblogs.net/shahed/archive/2007/09/05/115173.aspx[^]


嘿,只需按以下链接签出...对您有帮助

尝试一下

问候
koolprasad2003:)
Hey just checkout following link...will help u

Try This

regards
koolprasad2003 :)


这篇关于将会话超时页面重定向代码放在asp.net中的什么位置?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆