从Global.asax代码重定向到登录页面

时间:2015-02-02 10:13:59

标签: c# asp.net global-asax

我有一个回调方法,它只在容器控件中加载自定义用户控件,我在页面中使用表单身份验证,并将用户身份验证信息存储在我的页面用户身份Page.User.Identity中 我还使用Global.asax事件存储页面用户信息:

protected void Application_AuthenticateRequest(object sender, EventArgs e)
{
    if (HttpContext.Current.User.Identity.IsAuthenticated)
    {
         //Get Forms Identity From Current User
    } 
    else 
    {
         //redirect to login.aspx page
    }
} 

现在,当我调用该回调方法并且用户未经过身份验证时,回调不会触发,而是在global.asax上一个事件中触发的唯一代码。 从那个事件我需要重定向到login.aspx页面,我该如何实现?

0 个答案:

没有答案