凡究竟窗体身份验证存在于HTTP管道? [英] Where exactly does Forms Authentication exist in the Http Pipeline?

查看:113
本文介绍了凡究竟窗体身份验证存在于HTTP管道?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在哪里究竟窗体身份验证在HTTP管道存在吗?

Where exactly does Forms Authentication exist in the Http Pipeline?

推荐答案

想我早该这首想法,但直到我看到@Carl雷蒙德的答案我可以破解它打开它并没有对我黎明在反射器。因此,要回答我的问题。

Guess I should've thought of this first but it didn't dawn on me until I saw the answer from @Carl Raymond that I can just crack it open in reflector. So to answer my own question

public void Init(HttpApplication app)
{
    if (!_fAuthChecked)
    {
        _fAuthRequired = AuthenticationConfig.Mode == AuthenticationMode.Forms;
        _fAuthChecked = true;
    }
    if (_fAuthRequired)
    {
        FormsAuthentication.Initialize();
        app.AuthenticateRequest += new EventHandler(this.OnEnter);
        app.EndRequest += new EventHandler(this.OnLeave);
    }
}

的OnEnter 调用它通过在应用程序上下文中的私有方法 OnAuthenticate ,这是它验证/写出来表单验证门票。

OnEnter calls the private method OnAuthenticate which passes in the application context and this is where it validates/writes out the Form Auth tickets.

OnExit 它检查HTTP状态错误code 401的响应,如果它发现它,当它重定向到登录的URL。

In OnExit it checks the response for a Http Status Error Code 401 and if it finds it, that's when it redirects to the Login Url.

这篇关于凡究竟窗体身份验证存在于HTTP管道?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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