3

I know that Core 2 is moving away from the web.config and towards Json configuration. However, I have come across an issue where by my IIS 7 server has WebDav installed which is blocking HTTP PUT requests to my webapi.

The following link has provided a working solution by removing WebDav;

Remove WebDav Web.Config for Core 1

The issue I am having is that I need to add this to the generated web.config on the server with every publish as it is being over written each time.

Is it possible for me to add a web.config to my Asp.Net Core 2 webapi? or tell it to add this to the one it is generating?

2 Answers 2

1

In Asp.Net Core 2.1 I added web.config file into the root of project then remove WebDAV from module and handler

<system.webServer>
        <modules runAllManagedModulesForAllRequests="false" xdt:Transform="Insert" >
            <remove name="WebDAVModule" />
        </modules>
        <handlers>
            <remove name="WebDAV"/>
         </handlers>
</system.webServer>

The web.config file is generated when you are publishing the project. It works for me.

Sign up to request clarification or add additional context in comments.

Comments

0

You can just add 'copy always' property to any file to auto add it to the build folder.

enter image description here

also you can use config file transformations. I believe they should work with .Net Core. In your case you want to create web.release.config:

Right-click the Web.config file and then click Add Config Transforms.

<configuration xmlns:xdt="http://schemas.microsoft.com/XML-Document-Transform">
  <system.web>
    <compilation xdt:Transform="RemoveAttributes(debug)" />
  </system.web>
  <system.webServer>
    <modules runAllManagedModulesForAllRequests="false" xdt:Transform="Insert" >
      <remove name="WebDAVModule" />
    </modules>
  </system.webServer>
</configuration>

More information

Good example

6 Comments

But I’m using.net core
You can add 'copy always' property to any file to auto add it on build. Edited my answer.
Thanks for the deatiled answer, but the issue is I am using .net core 2. Visual Studio isn't giving me the option to add transformations to a web.config file, and errors when I try to debug if I add a web.config file to the project?
Publishing my Core 2 project generates the web.config and wondering how to bring this file into the solution/project for purposes of configuration management.
@MatthewFlynn Did you manage to find a solution to the .NET Core 2.0 web.config issue? I too need to remove the WebDav when I publish. Any help would be greatly appreciated.
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.