从母版页重定向到登录页 [英] Redirct to the login page from master page

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

问题描述

大家好,

我想在会话结束时从母版页重定向到登录页.
如果我在页面上是从母版页继承的,则当我单击按钮时,
形式做回发.在母版页Page_Load事件中,我正在检查会话
不再存在,然后重定向到登录页面,但是该页面不会重定向到
登录页面,并执行按钮事件,我不想在每个位置都放置会话复选标记.
那么,当用户会话退出时,如何从主表单的页面加载中重定向到登录页面?

Hi All,

i want to redirect to the login page from master page when session out.
If i am on a page inherit from a master page, when i click the button then
form do the postback. in master page Page_Load event i am checking if session
is no longer exist then redirct to the login page, but page do not redirect to the
login page, and button event execute, i don''t want to place session out check mark every where .
So how can i redirct to the login page when user session out, from page load of master form?

推荐答案

在您的MasterPage的Page_Load处理程序中,检查您的会话多变的.如果为空,请重定向到登录页面:

In the Page_Load handler of your MasterPage, check for your session variable. If it''s null, redirect to the login page:

if(Session["MyVariable"] == null)
{
    FormsAuthentication.RedirectToLoginPage();
}



http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.redirecttologinpage.aspx [ ^ ]



http://msdn.microsoft.com/en-us/library/system.web.security.formsauthentication.redirecttologinpage.aspx[^]


这篇关于从母版页重定向到登录页的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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