Web.config 转换删除了 Security 和 HttpProtocol 节点



当我将 Dotnet Core (2.x( 应用程序发布到我的发布配置时,Web.config 未正确转换。

当然,它有处理程序和aspNet Core元素,但所有的httpProtocol和安全节点都完全消失了!我在这里错过了什么吗?

Base/Dev Web.config

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="%LAUNCHER_PATH%" arguments="%LAUNCHER_ARGS%" requestTimeout="00:10:00" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" />
<security>
<requestFiltering>
<requestLimits maxAllowedContentLength="524288000" />
</requestFiltering>
</security>
<httpProtocol>
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>
</system.webServer>
</location>
</configuration>

在dotnet发布--configuration Server -o C:\MyWebs\publish之后

<?xml version="1.0" encoding="utf-8"?>
<configuration>
<location path="." inheritInChildApplications="false">
<system.webServer>
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".project.dll" stdoutLogEnabled="false" stdoutLogFile=".logsstdout" />
</system.webServer>
</location>
</configuration>

干杯。

最终使用 Web.release.config 修复了它,并使用 xdt:Transform 插入特定的 httpProtocol 和 Security 节点。

<httpProtocol xdt:Transform="Insert">
<customHeaders>
<add name="Access-Control-Allow-Origin" value="*" />
</customHeaders>
</httpProtocol>

最新更新