6

I published a .NET Core Web API through FTP.

By default, some of the methods weren't working(put and delete), because the server has WebDAV enabled as default.

To remove this, after publishing the application I have to manually go to web.config on FTP and add the following lines

  <modules runAllManagedModulesForAllRequests="false">
    <remove name="WebDAVModule" />
  </modules>

How would one go about it setting it up to be removed automatically - I assume through Startup.cs

Ade Stringer
  • 2,392
  • 14
  • 25
BroDev
  • 488
  • 1
  • 3
  • 13
  • https://stackoverflow.com/questions/48188895/asp-net-core-with-iis-http-verb-not-allowed this may help, and this seems to be a duplicate – Dreamweaver Mar 11 '20 at 16:17
  • As it seems, the answers to that question clarify the same solution which I have used. However, they don't answer the question which I've asked – BroDev Mar 11 '20 at 16:29
  • You can have web.config for production and DEV and while build / publish we can publish production webconfig. Will it not work ? – Dreamweaver Mar 12 '20 at 03:37
  • 2
    @Dreamweaver The standard VS2019 project doesn't contain web config as before. It gets created after publishing to the FTP and you need to manually override it, etc. The question is, how to simply remove WebDav through Startup.cs I think it should be possible – BroDev Mar 12 '20 at 13:30

2 Answers2

0

You only need to add web.config file to your API, and then when you publish automatically it will take your web.config.

-1

Add this code to your web config file:

   <system.webServer>
        <modules>
          <!-- Remove WebDAV module so that we can make DELETE requests -->
          <remove name="WebDAVModule" />
        </modules>
        <handlers>
          <!-- Remove WebDAV module so that we can make DELETE requests -->
          <remove name="WebDAV" />
          <add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" />
        </handlers>
    
        other configs here...
    
    
    </system.webServer>
funie200
  • 2,683
  • 4
  • 16
  • 27
  • The question is not about how to Remove WebDAV with .NET Core. The question is about how to automate the process. Thank you – BroDev Dec 08 '20 at 17:16