I have some trouble while publish the custom web.config I created in my application which I developed using .net Core 3.1. I use Visual Studio 2019.
My web.config (which it work as I want if I manually update it in the server)
<?xml version="1.0" encoding="utf-8" ?>
<configuration >
<system.webServer >
<handlers>
<add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
</handlers>
<aspNetCore processPath="dotnet" arguments=".\myapplication.dll" stdoutLogEnabled="false"
stdoutLogFile=".\logs\stdout" hostingModel="inprocess" />
<security>
<authentication>
<anonymousAuthentication enabled="false" />
</authentication>
</security>
</system.webServer>
<location path="images">
<system.web>
<authorization>
<allow users="*" />
</authorization>
</system.web>
<system.webServer>
<security>
<authentication>
<anonymousAuthentication enabled="true" />
</authentication>
</security>
</system.webServer>
</location>
</configuration>
the structure in my project is
web.config
|
|--- web.Debug.config
|--- web.Release.config
web.Release.config has "Content" as "Build Action" and "Copy If Newer" as "Copy to output directory" web.config contains only
<?xml version="1.0" encoding="utf-8" ?>
<configuration >
</configuration>
I tried to use web.config file transformation: https://docs.microsoft.com/en-us/aspnet/web-forms/overview/deployment/visual-studio-web-deployment/web-config-transformations
but it end up in a mess. I put "xdt:Transform="Insert"" in both tag "system.webServer" and "location". The system add both twice in the created web.config (on the server) and leave the default tag location.
Can you help me?