asp.net - FormsAuthenticationModule 在哪里注册?

标签 asp.net asp.net-mvc authentication

现在我正在尝试详细了解 asp.net mvc 身份验证的工作原理。据我了解,FormsAuthenticationModule 检查 cookie 并填充 HttpContext.User。但我找不到为我的应用程序注册 FormsAuthenticationModule 的位置?

最佳答案

它继承自根web.config。例如,如果您在 x64 计算机上安装了 .NET 4,请打开 C:\Windows\Microsoft.NET\Framework64\v4.0.30319\Config\web.config。在 system.web 部分中,您会发现已注册以下模块:

<httpModules>
    <add name="OutputCache" type="System.Web.Caching.OutputCacheModule" />
    <add name="Session" type="System.Web.SessionState.SessionStateModule" />
    <add name="WindowsAuthentication" type="System.Web.Security.WindowsAuthenticationModule" />
    **<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />**
    <add name="PassportAuthentication" type="System.Web.Security.PassportAuthenticationModule" />
    <add name="RoleManager" type="System.Web.Security.RoleManagerModule" />
    <add name="UrlAuthorization" type="System.Web.Security.UrlAuthorizationModule" />
    <add name="FileAuthorization" type="System.Web.Security.FileAuthorizationModule" />
    <add name="AnonymousIdentification" type="System.Web.Security.AnonymousIdentificationModule" />
    <add name="Profile" type="System.Web.Profile.ProfileModule" />
    <add name="ErrorHandlerModule" type="System.Web.Mobile.ErrorHandlerModule, System.Web.Mobile, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a" />
    <add name="ServiceModel" type="System.ServiceModel.Activation.HttpModule, System.ServiceModel.Activation, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35" />
    <add name="UrlRoutingModule-4.0" type="System.Web.Routing.UrlRoutingModule" />
    <add name="ScriptModule-4.0" type="System.Web.Handlers.ScriptModule, System.Web.Extensions, Version=4.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35"/>
</httpModules>

ASP.NET 将其与它在文件系统层次结构中找到的所有 web.config 文件合并,以便应用程序默认启用所有模块。

关于asp.net - FormsAuthenticationModule 在哪里注册?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20163911/

相关文章:

ios - 在哪里获取服务器上GameCenter 3rd 方身份验证的公钥

security - 限制对 Jenkins Web 仪表板的访问

c# - 在用户控件上更改运行时 UI 的最佳方法?

asp.net - CMS(Web 应用程序或 Windows 应用程序)

c# - 如何清除插入之间的 FormView 数据

asp.net - 如何使用 View 中的下拉列表将数据从 ViewModel 插入到数据库

c# - 当一项操作完成时,如何将某人从 ASP.NET MVC 中的一项操作重定向到另一项操作?

c# - ASP.NET MVC 使用 View 中的值填充 DropDownList

asp.net - 多个表的业务对象

powershell - Databricks API 2.0 - 使用服务主体凭据在 powershell 中创建 secret 范围