ASP.NET MVC 5 Web.config:“FormsAuthenticationModule"或“FormsAuthentication" [英] ASP.NET MVC 5 Web.config: "FormsAuthenticationModule" or "FormsAuthentication"

查看:15
本文介绍了ASP.NET MVC 5 Web.config:“FormsAuthenticationModule"或“FormsAuthentication"的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

好吧,这没什么大不了的,但它困扰着我,我不能放手.

Ok so this not a big deal, but it's bugging me and I can't let it go.

所以我将 MVC 5.1 与 .NET 4.5.1 和 OWIN 身份验证一起使用.所以当你创建一个新的MVC 5项目时,以下内容会自动添加到Web.config中以摆脱表单身份验证http模块,因为在使用OWIN中间件时不再需要它:

So I'm using MVC 5.1 with .NET 4.5.1 and OWIN authentication. So when you create a new MVC 5 project, the following is automatically added to the Web.config to get rid of the forms authentication http module because it is no longer needed when using OWIN middleware:

<system.webServer>
    <modules>
        <remove name="FormsAuthenticationModule" />
    </modules>
</system.webServer>

现在由于我们正在删除该模块,这意味着它之前已添加,因此这里是在 C:WindowsMicrosoft.NETFrameworkv4.0.30319Configweb 中注册此 http 模块的条目.配置:

Now since we are removing the module, that means it was previously added, so here is the entry registering this http module in C:WindowsMicrosoft.NETFrameworkv4.0.30319Configweb.config:

<httpModules>
    <add name="FormsAuthentication" type="System.Web.Security.FormsAuthenticationModule" />
</httpModules>

这是 IIS 8.5 中 C:WindowsSystem32inetsrvconfigapplicationHost.config 中的条目,它告诉我的应用程序使用该模块:

And here is the entry in C:WindowsSystem32inetsrvconfigapplicationHost.config for IIS 8.5 that tells my application to use the module:

<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 的最新变化还是我遗漏了什么?

So what is automatically added to my web config at the application level has a name attribute of "FormsAuthenticationModule" while the entries in the two server level/asp.net level config files use name attribute "FormsAuthentication". So what is going on here? It seems to me that the module won't be removed since the name attribute doesn't match. I would simply think this was a typo, but after searching online, everyone seems to be using "FormsAuthenticationModule" in the application web.config. Was this a recent change in the newer version of asp.net / iis or am I missing something?

推荐答案

你说得对 -- 这是模板中的一个错字.

You're right -- that's a typo in the template.

这篇关于ASP.NET MVC 5 Web.config:“FormsAuthenticationModule"或“FormsAuthentication"的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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