【问题标题】:How to do MVC authentication through custom httpmodule如何通过自定义httpmodule做MVC认证
【发布时间】:2010-11-10 18:15:56
【问题描述】:

有一个遗留应用程序,并从那里调用我的 MVC 应用程序。 我打算使用自定义httpmodule [AuthenticationModule 类继承IHttpModule]。在 Init 中,我连接了 BeginRequest 并执行了我的 FormAuthenication 工作......

     private void Application_BeginRequest(Object source, EventArgs e) {

         // Do my own authetication and issue FormAuthentication Ticket
    }

在 web.config 中:

    <system.webServer>
    <validation validateIntegratedModeConfiguration="false"/>
    <modules runAllManagedModulesForAllRequests="true">
        <add name="AuthenticationModule" type="RealProperty.LegacySecurity.AuthenticationModule, RealProperty.LegacySecurity" preCondition="ManagedHandler"/>
    </modules>

但我的 AuthenticationModule 在调试时从未起火... (1) 谁能解释为什么它没有被调用? (2) 在 BeginRequest 中进行身份验证是否正确?

【问题讨论】:

    标签: model-view-controller httpmodule


    【解决方案1】:

    确保您的 Web.config 文件中包含这两个部分:

    <system.web>
      <httpModules>
        <add name="MyAuthenticationModule" type="Ns.To.MyAuthenticationModule, MyAssembly" />
      </httpModules>
    </system.web>
    
    <system.webServer>
      <modules runAllManagedModulesForAllRequests="true">
        <add name="MyAuthenticationModule" type="Ns.To.MyAuthenticationModule, MyAssembly" />
      </modules>
    </system.webServer>
    

    【讨论】:

      猜你喜欢
      • 2018-10-30
      • 2010-12-08
      • 1970-01-01
      • 2013-04-12
      • 1970-01-01
      • 2013-12-13
      • 1970-01-01
      • 1970-01-01
      • 2011-12-12
      相关资源
      最近更新 更多