【发布时间】:2021-10-20 00:33:02
【问题描述】:
在 ASP .NET 5 中,Configuration 正在发生巨大变化。我们不再有web.config 文件。相反,我们可以使用 JSON 和其他选项,这取决于我们在 Startup 类中的设置方式。与web.config 不同,此类配置通常不会进入wwwroot,并且不存在客户端可以访问它的危险。
然而,在 ASP .NET 5 项目模板中,wwwroot 中有一个 web.config 文件,其内容如下:
<?xml version="1.0" encoding="utf-8"?>
<configuration>
<system.webServer>
<handlers>
<add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified"/>
</handlers>
<httpPlatform processPath="%DNX_PATH%" arguments="%DNX_ARGS%" stdoutLogEnabled="false" startupTimeLimit="3600"/>
</system.webServer>
</configuration>
在我看来,这可能是托管服务器在运行时寻找的东西,与应用程序配置无关。
谁能解释一下为什么需要这样做,以及它是如何工作的?
【问题讨论】:
-
这还需要吗?
-
是的,如果你在 IIS 中托管 ASP .NET Core,你仍然需要 web.config,尽管配置文件的实际内容可能已经改变。
-
我的 web.config 文件不在 wwwroot/ 文件夹中。我只是想知道我是否需要具有 AspNetCore IIS 模块的普通 web.config 和上面显示的位于 wwwroot 中的 web.config。
-
我认为您只需要带有 AspNetCore IIS 模块的那个。回想起来,我不记得当时在 wwwroot 中使用 web.config 是个好主意。