Reputation: 3941
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?
Upvotes: 3
Views: 4553
Reputation: 43
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.
Upvotes: 1
Reputation: 535
You can just add 'copy always' property to any file to auto add it to the build folder.
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>
Upvotes: 0