ASP.NET MVC 5 Web.config : "FormsAuthenticationModule" or "FormsAuthentication"
oomusou
阅读:67
2025-06-02 22:19:02
评论:0
好的,所以这没什么大不了的,但它困扰着我,我不能放手。
所以我将 MVC 5.1 与 .NET 4.5.1 和 OWIN 身份验证一起使用。因此,当您创建一个新的 MVC 5 项目时,以下内容会自动添加到 Web.config 以摆脱表单例份验证 http 模块,因为在使用 OWIN 中间件时不再需要它:
<system.webServer>
<modules>
<remove name="FormsAuthenticationModule" />
</modules>
</system.webServer>
现在,由于我们要删除该模块,这意味着它是以前添加的,所以这里是在
C:\Windows\Microsoft.NET\Framework\v4.0.30319\Config\web.config 中注册此 http 模块的条目:
<httpModules>
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
</httpModules>
这是
C:\Windows\System32\inetsrv\config\applicationHost.config 中的条目对于 IIS 8.5,它告诉我的应用程序使用该模块:
<system.webServer>
<modules>
<add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" preCondition="managedHandler" />
</modules>
</system.webServer>
因此,在应用程序级别自动添加到我的 Web 配置中的内容具有名称属性“FormsAuthenticationModule”,而两个服务器级别/asp.net 级别配置文件中的条目使用名称属性“FormsAuthentication”。那么这里发生了什么?在我看来,模块不会被删除,因为 name 属性不匹配。我只是认为这是一个错字,但在网上搜索后,每个人似乎都在应用程序 web.config 中使用“FormsAuthenticationModule”。这是最新版本的 asp.net/iis 的最新变化还是我遗漏了什么?
请您参考如下方法:
你是对的 - 这是模板中的一个错字。
声明
1.本站遵循行业规范,任何转载的稿件都会明确标注作者和来源;2.本站的原创文章,请转载时务必注明文章作者和来源,不尊重原创的行为我们将追究责任;3.作者投稿可能会经我们编辑修改或补充。



