<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:dc="http://purl.org/dc/elements/1.1/">
  <channel>
    <title>DEV Community: Samuel Babatunde</title>
    <description>The latest articles on DEV Community by Samuel Babatunde (@devvsamjuel).</description>
    <link>https://dev.to/devvsamjuel</link>
    <image>
      <url>https://media2.dev.to/dynamic/image/width=90,height=90,fit=cover,gravity=auto,format=auto/https:%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Fuser%2Fprofile_image%2F658405%2F5387441c-39ba-439f-a65e-3f97adf1aa06.jpg</url>
      <title>DEV Community: Samuel Babatunde</title>
      <link>https://dev.to/devvsamjuel</link>
    </image>
    <atom:link rel="self" type="application/rss+xml" href="https://dev.to/feed/devvsamjuel"/>
    <language>en</language>
    <item>
      <title>How to enable PUT and DELETE Http Verbs on your IIS Website by removing WebDAV feature on Windows Server and Desktop machines.</title>
      <dc:creator>Samuel Babatunde</dc:creator>
      <pubDate>Mon, 13 Jun 2022 18:29:44 +0000</pubDate>
      <link>https://dev.to/devvsamjuel/webdav-put-and-delete-http-verbs-remove-webdav-module-on-iis-3l1g</link>
      <guid>https://dev.to/devvsamjuel/webdav-put-and-delete-http-verbs-remove-webdav-module-on-iis-3l1g</guid>
      <description>&lt;p&gt;&lt;em&gt;For dear lazy reader: scroll down to &lt;strong&gt;Summary&lt;/strong&gt; then up to &lt;strong&gt;Solutions&lt;/strong&gt;, you are good to go!&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Background
&lt;/h2&gt;

&lt;p&gt;So, I deployed a web app (ASP.NET Core Web API) on &lt;a href="https://en.wikipedia.org/wiki/Internet_Information_Services" rel="noopener noreferrer"&gt;IIS&lt;/a&gt; through Azure DevOps Pipeline. While I could make requests to endpoints using &lt;code&gt;POST&lt;/code&gt; and &lt;code&gt;GET&lt;/code&gt;, I couldn't make HTTP calls to endpoints designated with &lt;code&gt;PUT&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; Verbs.&lt;/p&gt;

&lt;p&gt;Like every other Software Developer, I went online to source for answers. &lt;a href="https://stackoverflow.com/questions/48188895/asp-net-core-with-iis-http-verb-not-allowed" rel="noopener noreferrer"&gt;Stackoverflow&lt;/a&gt; is always my first choice, there I learnt that I need to add some configurations in the web.config file on the server to remove "WebDAVModule" (Bear with me, I will explain).&lt;/p&gt;

&lt;p&gt;This I did by &lt;a href="https://en.wikipedia.org/wiki/Remote_Desktop_Protocol" rel="noopener noreferrer"&gt;RDP&lt;/a&gt;ing (going into a remote computer from your computer using a GUI as opposed to the CLI) to the server, editing the &lt;em&gt;web.config&lt;/em&gt; file (an XML file for configuration) and everything was fine. &lt;/p&gt;

&lt;p&gt;But because I need to run the release pipeline every other time on Azure DevOps to make new deployments, the &lt;em&gt;web.config&lt;/em&gt; file gets replaced and I'm back to where I was initially, needing to do the manual "WebDAVModule" thingy again. RDPing to the server and editing the &lt;em&gt;web.config&lt;/em&gt; again and again. Infuriating!. &lt;/p&gt;

&lt;p&gt;Trying to rid myself of this frustration, a couple of questions popped, one question led to another question in the following order;&lt;/p&gt;

&lt;ul&gt;
&lt;li&gt;&lt;p&gt;How to edit the &lt;em&gt;web.Config&lt;/em&gt; file on Azure DevOps Pipeline on a new release?&lt;em&gt;(coming soon)&lt;/em&gt;.&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;How to permanently disable the &lt;em&gt;WebDAV Module&lt;/em&gt;?&lt;/p&gt;&lt;/li&gt;
&lt;li&gt;&lt;p&gt;What is the relationship WebDAV and HTTP Verbs?&lt;/p&gt;&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  What is WebDAV?
&lt;/h2&gt;

&lt;p&gt;Story time… Don’t worry it’s a short one, really. Nah…&lt;/p&gt;

&lt;p&gt;In 1989 while working at &lt;a href="https://en.wikipedia.org/wiki/CERN" rel="noopener noreferrer"&gt;CERN&lt;/a&gt; in Switzerland, amongst other things, Tim Berners-Lee invented the World Wide Web and the web browser called &lt;em&gt;WorldWideWeb&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;Unlike what we can do with web browsers today, back then you could not only view web pages, you could also edit them right there on your browser like you would do over FTP, making your web server act like a file server. &lt;/p&gt;

&lt;p&gt;As time went by this changed and now you can only view web pages in your browser.&lt;/p&gt;

&lt;p&gt;A group of guys led by Jim Whitehead decided to remove this limitation and restore the old functionalities so that you could edit contents on the web server from your web browser. This birthed WebDAV. &lt;/p&gt;

&lt;p&gt;&lt;strong&gt;End of story&lt;/strong&gt;. &lt;/p&gt;

&lt;p&gt;WebDAV gives the server a new set of abilities which include file manipulation and version tracking. &lt;/p&gt;

&lt;p&gt;If you don't fret at the sight of technical jargons, check out the full story &lt;a href="https://www.cloudwards.net/what-is-webdav/" rel="noopener noreferrer"&gt;here&lt;/a&gt;, I am sure this link also has links to more technical jargons. Goodluck!&lt;/p&gt;

&lt;p&gt;So, let’s define WebDAV…&lt;/p&gt;

&lt;p&gt;&lt;em&gt;WebDAV stands for Web Distributed Authoring and Versioning, it adds more methods and headers to the set of standard HTTP headers and methods to let you create, move and edit files, as well as delete or copy files and folders&lt;/em&gt;.&lt;/p&gt;

&lt;p&gt;&lt;em&gt;Beyond these actions, it also has features that allow versioning, that is, keeping track of changes made to files and folders on the web server simultaneously by multiple users communicating with the web server&lt;/em&gt;. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;Consequently, this facilitates collaboration just like with GitHub. WebDAV is a powerful extension to the HTTP protocol&lt;/em&gt;. More info &lt;a href="https://www.cloudwards.net/what-is-webdav/" rel="noopener noreferrer"&gt;here&lt;/a&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Relationship between WebDAV and HTTP Verbs?
&lt;/h2&gt;

&lt;p&gt;When you make HTTP requests with your web browsers (or Postman) to  web servers that have WebDAV modules installed, you are limited to &lt;code&gt;GET&lt;/code&gt; and &lt;code&gt;POST&lt;/code&gt; &lt;code&gt;HTTP&lt;/code&gt; Verbs. &lt;/p&gt;

&lt;p&gt;That is, you can read and create contents on a web server through your browser, but you can’t &lt;code&gt;PUT&lt;/code&gt; or &lt;code&gt;DELETE&lt;/code&gt;. &lt;/p&gt;

&lt;p&gt;This happens because PUT and DELETE are part of WebDAV verbs  and the &lt;em&gt;WebDAV module&lt;/em&gt; claims incoming requests with these verbs and returns “405 Method not allowed” response. &lt;/p&gt;

&lt;p&gt;&lt;em&gt;The solution would be to remove the WebDAV module from your IIS site or web server altogether&lt;/em&gt;.&lt;/p&gt;

&lt;h2&gt;
  
  
  Assumptions
&lt;/h2&gt;

&lt;ul&gt;
&lt;li&gt;You have access to your app web server.&lt;/li&gt;
&lt;li&gt;Your app is deployed on Windows server.&lt;/li&gt;
&lt;li&gt;Your app is on IIS.&lt;/li&gt;
&lt;/ul&gt;

&lt;h2&gt;
  
  
  Solutions
&lt;/h2&gt;

&lt;p&gt;While WebDAV is supported on various servers, including the Apache HTTP server, the SabreDAV server, Nginx server, ownCloud and Nextcloud, this article focuses on Microsoft’s Internet Information Services (IIS). &lt;/p&gt;

&lt;p&gt;To be able to make &lt;code&gt;PUT&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; requests to your web app, you need to remove &lt;em&gt;WebDAV Module&lt;/em&gt; on IIS website or remove the WebDAV feature from your app server. &lt;/p&gt;

&lt;p&gt;The following are 3 ways you can do this;&lt;/p&gt;

&lt;h4&gt;
  
  
  1. Manually edit &lt;em&gt;web.config&lt;/em&gt; to disable WebDAV (The Quick one but not the best):
&lt;/h4&gt;

&lt;p&gt;You just need  to set your &lt;em&gt;Web.Config&lt;/em&gt; file as follows to remove the WebDAV module from the application:&lt;/p&gt;

&lt;div class="highlight js-code-highlight"&gt;
&lt;pre class="highlight plaintext"&gt;&lt;code&gt;

&amp;lt;?xml version="1.0" encoding="utf-8"?&amp;gt;
&amp;lt;configuration&amp;gt;
  &amp;lt;location path="." inheritInChildApplications="false"&amp;gt;
    &amp;lt;system.webServer&amp;gt;
    &amp;lt;modules&amp;gt; 
                        &amp;lt;remove name="WebDAVModule" /&amp;gt; 
         &amp;lt;/modules&amp;gt; 
      &amp;lt;handlers&amp;gt;
           &amp;lt;add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /&amp;gt;
      &amp;lt;/handlers&amp;gt;
      &amp;lt;aspNetCore processPath="dotnet" arguments=".\[app name].dll" stdoutLogEnabled="false" stdoutLogFile=".\logs\stdout" hostingModel="inprocess"&amp;gt;
                &amp;lt;environmentVariables&amp;gt;
                    &amp;lt;environmentVariable name="ASPNETCORE_ENVIRONMENT" value="Staging" /&amp;gt;
                &amp;lt;/environmentVariables&amp;gt;
            &amp;lt;/aspNetCore&amp;gt;
    &amp;lt;/system.webServer&amp;gt;
  &amp;lt;/location&amp;gt;
&amp;lt;/configuration&amp;gt;


&lt;/code&gt;&lt;/pre&gt;

&lt;/div&gt;

&lt;p&gt;&lt;strong&gt;N.B.&lt;/strong&gt;: &lt;em&gt;This solution only affects the current application (website).To apply this to all the applications on IIS, check solution 3&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  2.  Disable WebDAVModule in the Internet Information Services Manager:
&lt;/h4&gt;

&lt;p&gt;a. Open the &lt;em&gt;IIS Manager&lt;/em&gt; and navigate to the website. &lt;br&gt;
b. Double-click the &lt;em&gt;Handler Mappings&lt;/em&gt; item. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zue9gll5p6ur4q6nw4y.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F6zue9gll5p6ur4q6nw4y.png" alt="IIS window showing _Handler Mappings_."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. Right click WebDAV and select Remove.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8yb6hssqi4ardg04ymm9.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F8yb6hssqi4ardg04ymm9.png" alt="IIS window showing WebDAV under _Handler Mappings_."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. Navigate back to your website. &lt;br&gt;
 e. Double-click the &lt;em&gt;Modules&lt;/em&gt; item. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F744xizt16dmum84a2axw.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F744xizt16dmum84a2axw.png" alt="IIS window showing showing WebDAV "&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;f. Right click &lt;em&gt;WebDAVModule&lt;/em&gt; and select Remove.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flg1px1lcjxt24p2t22uv.jpg" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Flg1px1lcjxt24p2t22uv.jpg" alt="IIS window showing WebDAV under _Modules_ item."&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;N.B.&lt;/strong&gt;: &lt;em&gt;This solution only affects the current application  (website).To apply this to all the applications on IIS, check solution 3&lt;/em&gt;.&lt;/p&gt;

&lt;h4&gt;
  
  
  3. Remove the WebDAV Publishing feature on Windows
&lt;/h4&gt;

&lt;h5&gt;
  
  
  On a Windows Server:
&lt;/h5&gt;

&lt;p&gt;a. Open the &lt;em&gt;Server Manager&lt;/em&gt; and select "Manage",&lt;/p&gt;

&lt;p&gt;b. Select "Remove Roles and Features", &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvp1wshntkka5hyzi2oi2.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fvp1wshntkka5hyzi2oi2.png" alt="_Windows Server Manager_ showing _Manage_ option selected"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. jump to the "Server Roles" section and uncheck the following option: Web Server (IIS) &amp;gt; Web Server &amp;gt; Common HTTP Features &amp;gt; WebDAV Publishing.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fun2hvp3kthtmcp4agp2f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fun2hvp3kthtmcp4agp2f.png" alt="_Windows Server Manager_ showing _WebDAV Publishing_ unchecked"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. Select "Next" until you can select "Remove" on the Confirmation section.&lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmpb24vv1p4sldmoui9v.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2Fkmpb24vv1p4sldmoui9v.png" alt="_Windows Server Manager_ showing removal of _WebDAV Publishing_"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;e. You may need to restart the server for the change to take effect.&lt;/p&gt;

&lt;h5&gt;
  
  
  On Windows Desktop:
&lt;/h5&gt;

&lt;p&gt;a. Open a Windows Explorer window and navigate to Control Panel\All Control Panel Items\Programs and Features.&lt;/p&gt;

&lt;p&gt;b. Select the Turn Windows features on or off option. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fkpms7j6355y9apriln.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F3fkpms7j6355y9apriln.png" alt="Screenshot showing _Control Panel_ and _"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;c. Uncheck the following option: Internet Information Services &amp;gt; World Wide Web Services &amp;gt; Common HTTP Features &amp;gt; WebDAV Publishing. &lt;/p&gt;

&lt;p&gt;&lt;a href="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F862j04lyfpcdlejhqi2f.png" class="article-body-image-wrapper"&gt;&lt;img src="https://media.dev.to/dynamic/image/width=800%2Cheight=%2Cfit=scale-down%2Cgravity=auto%2Cformat=auto/https%3A%2F%2Fdev-to-uploads.s3.amazonaws.com%2Fuploads%2Farticles%2F862j04lyfpcdlejhqi2f.png" alt="Screenshot showing _Control Panel_ and showing _WebDAV Publishing_ unchecked"&gt;&lt;/a&gt;&lt;/p&gt;

&lt;p&gt;d. Click OK. You may need to restart the server for the change to take effect.&lt;/p&gt;

&lt;h2&gt;
  
  
  Summary
&lt;/h2&gt;

&lt;p&gt;WebDAV is a set of extensions to the HTTP protocol which allows users to collaboratively edit and manage files on remote web servers. &lt;/p&gt;

&lt;p&gt;WebDAV module is a feature on Windows Server that allows the web server to have WebDAV functionalities.&lt;/p&gt;

&lt;blockquote&gt;
&lt;p&gt;If WebDAV is installed on the server, it becomes the first handler of HTTP requests, and intercepts all &lt;code&gt;PUT&lt;/code&gt; and &lt;code&gt;DELETE&lt;/code&gt; requests, so they don’t even reach your Web application.&lt;/p&gt;
&lt;/blockquote&gt;

&lt;p&gt;The simplest &lt;strong&gt;Solution&lt;/strong&gt; is to uninstall WebDAV on your server using the &lt;em&gt;Server Manager&lt;/em&gt; application.&lt;/p&gt;

&lt;p&gt;&lt;strong&gt;End of article&lt;/strong&gt;. &lt;/p&gt;

</description>
      <category>iis</category>
      <category>webdav</category>
      <category>http</category>
      <category>aspnetcore</category>
    </item>
  </channel>
</rss>
