title: webdav WebClient.Upload (401) Unauthorized
body: <p>Im trying to upload a file to a webdav server but i get (401) Unauthorized. I cant figure out if my problem is with rights on the server or with my code? This is the code im using to test this:</p>
  <pre><code>string sourceFilePath = @&quot;C:\testfile.txt&quot;;
  string webAddress = &quot;http://ip:port/&quot;;
  string destinationFilePath = webAddress + &quot;testfile.txt&quot;;
  
  WebClient webClient = new WebClient();
  webClient.UseDefaultCredentials = true;
  webClient.UploadFile(destinationFilePath, &quot;PUT&quot;, sourceFilePath);
  webClient.Dispose();
  </code></pre>
  <p>However using the following code i can download files from the webdav server:</p>
  <pre><code>string webAddress = &quot;http://ip:port/&quot;;
  string sourceFilePath = webAddress + &quot;testfile.txt&quot;;
  string destinationFilePath = @&quot;C:\testfile.txt&quot;;
  
  WebClient webClient = new WebClient();            
  webClient.UseDefaultCredentials = true;
  webClient.DownloadFile(sourceFilePath, destinationFilePath);
  webClient.Dispose();
  </code></pre>
  <p>The server is running iis 8 with webdav authoring rule configured.
  I have set full control for my user on the target folder at the server.</p>
  <p>Edit: Realized that even if I remove the authoring rule i can download the file, why is this?</p>
  <p>Authoring rule looks like this:</p>
  <p><a href="https://i.stack.imgur.com/KTwxz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KTwxz.png" width="456" height="593"></a></p>