会话输出页面重定向问题 [英] Session out Problem for page redirect

查看:88
本文介绍了会话输出页面重定向问题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

当我们将网址复制到另一个浏览器时,应使用this将此网址重定向到登录页面,但是,如果用户停留在同一页面上而未执行任何操作,则会显示错误消息msg.如何保持会话时间

这是我的代码:
在Global.asax中

when we copy the url to another browser it should be redirected to login page ,am using lik this ,But if user stay on the same page without doing any action it displays error msg.how to maintain the session time

Here is my code:
in Global.asax

        protected void Session_Start(object sender, EventArgs e)
        {
            Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~\\Home.aspx"));
        }

        protected void Session_End(object sender, EventArgs e)
        {
            Response.Redirect(Request.Url.GetLeftPart(UriPartial.Authority) + VirtualPathUtility.ToAbsolute("~\\Home.aspx"));
        }
    }
}

推荐答案

检查此博客
http://www.dotnetcurry.com/ShowArticle.aspx?ID=453 [ ^ ]
--NDK
check this blog
http://www.dotnetcurry.com/ShowArticle.aspx?ID=453[^]
--NDK


如果要保持会话有效,必须从浏览器进行一些活动.请记住,这是一个无状态的环境,一旦页面被提供,服务器就会忘记它.它不知道浏览器是关闭,导航到另一个站点还是用于午餐.您可以使用AJAX方法异步调用方法,以便重置会话超时.虽然,会话超时是有目的的,您应该在覆盖之前评估自己的需求.
If you want to keep the session alive there must be some activity from the browser. Remember this is a stateless environment and once the page is served the server forgets about it. It doesn''t know if the browser was closed, navigated to another site or the use went to lunch. You could use an AJAX method to asynchronously call a method so the session timeout would reset. Although, having a session timeout has a purpose and you should evaluate your need before overriding it.


这篇关于会话输出页面重定向问题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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