3

I have made changes to the web.config via Kudu for a .NET core 3.0 application running on Azure App Service, yet it seems when the site is deployed via Azure pipelines those changes I've made within the web.config is overwritten.

Our solution (.sln) doesn't include or have a web.config file.

Am I meant to explicitly include a web.config within our project and then that wouldn't occur?

Thanks for any help

Andrew Duffy
  • 795
  • 2
  • 17
  • 37
  • Regarding this question, I hope my answer is helpful to you.^-^ – Jason Pan May 19 '20 at 01:44
  • I'd also like to know since I'm using web.config to enable double escape sequencing in the URL. Azure App Service doesn't expose that capability in the Configuration page. – Alex. A Oct 27 '20 at 22:07

2 Answers2

1
<ItemGroup>
    <Content Update="Configuration\web.config">
        <Link>%(Filename)%(Extension)</Link>
        <CopyToOutputDirectory>Always</CopyToOutputDirectory>
        <CopyToPublishDirectory>Always</CopyToPublishDirectory>
    </Content>
</ItemGroup>

For more details, you can refer to the content of these two websites.

1、 https://github.com/dotnet/websdk/issues/564

2、 https://developercommunity.visualstudio.com/content/problem/162961/aspnet-core-app-with-a-webconfig-cannot-use-iis-ex.html

ThomasArdal
  • 4,999
  • 4
  • 33
  • 73
Jason Pan
  • 15,263
  • 1
  • 14
  • 29
1

Yes you need to have web.config file in root directory. I had to put web.config for a angular app on app service. Also, using the web.config values in App Service is not recommended. Use the Configuration link on app service (see screenshot below) to store app settings and connection strings. The values in app service configuration override the ones specified in web.config file. This way you keep your config values for different env separate and manageable. If you still want to use web.config values, you can have web.config transform in your solution to transform web.config for different envs. That way you can control the values for different env and have it versioned automatically as it would be part of your code repo. Hope that makes sense. Follow this link for web.config transformation.

enter image description here

rohit
  • 666
  • 8
  • 24
  • Dotnet core app don't have web.config file. Op want web.config file which he added will don't modify when deployed. – Jason Pan May 15 '20 at 09:47
  • True. But the question talks about making changes to web.config on app service. Hence my answer was directed towards that approach. – rohit May 15 '20 at 09:57