会话超时上的asp.net重定向到主页 [英] asp.net on session timeout redirect to home page
问题描述
我有Web应用,并且页面上有会话超时和用户交互,因此需要重定向到首页/着陆页
网上找到的解决方案
1)在应用程序的所有aspx页面的page_load中进行会话检查. 2)global.asax会话开始中的代码
public void Session_Start
{
Response.Redirect("home.aspx");
// or Server.Transfer("home.aspx");
}
我要选择第二个选项,请告诉我 1)我是否以正确的方式或对此有更好的解决方案? 2)在第二个选项中,是否使用Response.Redirect或Server.Transfer
-谢谢
为什么不使用JavaScript呢?您可以使用像
public void Session_Start
{
Response.Redirect("home.aspx");
// or Server.Transfer("home.aspx");
}
这样的方法
<script type="text/javascript">
setTimeout('window.location = "home.aspx"', 3000);
</script>
将上述js代码块放入页面标题(会话超时为3000)中.
i have web app and on session timeout and user interaction on the page, this needs to redirect to home/landing page
solutions found on the net
1) Session check in page_load of all the aspx pages of the application. 2) code in session start of global.asax
public void Session_Start
{
Response.Redirect("home.aspx");
// or Server.Transfer("home.aspx");
}
I am going for 2nd option,let me know 1) whether i am in right way or any better solutions for this? 2) in the second option whether to use Response.Redirect or Server.Transfer
-Thanks
Why don't you use JavaScript to do it? you can use setTimeout
method like
<script type="text/javascript">
setTimeout('window.location = "home.aspx"', 3000);
</script>
Put the above js code block into the page header which 3000 is your session timeout.
这篇关于会话超时上的asp.net重定向到主页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!