From 5cf65703b4c6c5fd932e2cff7358a137ec74a67f Mon Sep 17 00:00:00 2001
From: Michael <mi@art-ist.cc>
Date: Fri, 3 Mar 2017 08:49:56 +0100
Subject: [PATCH] - add: MS-Author-Via header

---
 .../MethodHandlers/WebDavOptionsMethodHandler.cs          | 8 +++++++-
 1 file changed, 7 insertions(+), 1 deletion(-)

diff --git a/WebDavSharp_MVC/WebDAVSharp.Server/MethodHandlers/WebDavOptionsMethodHandler.cs b/WebDavSharp_MVC/WebDAVSharp.Server/MethodHandlers/WebDavOptionsMethodHandler.cs
index 9abab73..10484b5 100644
--- a/WebDavSharp_MVC/WebDAVSharp.Server/MethodHandlers/WebDavOptionsMethodHandler.cs
+++ b/WebDavSharp_MVC/WebDAVSharp.Server/MethodHandlers/WebDavOptionsMethodHandler.cs
@@ -27,8 +27,8 @@ namespace WebDAVSharp.Server.MethodHandlers {
 		/// objects to use.</param>
 		/// <param name="store">The <see cref="IWebDavStore" /> that the <see cref="WebDavServer" /> is hosting.</param>
 		public void ProcessRequest(WebDavServer server, HttpContext context, IWebDavStore store, String fileName) {
-			List<string> verbsAllowed = new List<string> { "OPTIONS", "TRACE", "GET", "HEAD", "POST", "COPY", "PROPFIND", "LOCK", "UNLOCK" };
 
+			List<string> verbsAllowed = new List<string> { "OPTIONS", "TRACE", "GET", "HEAD", "POST", "COPY", "PROPFIND", "LOCK", "UNLOCK" };
 			List<string> verbsPublic = new List<string> { "OPTIONS", "GET", "HEAD", "PROPFIND", "PROPPATCH", "MKCOL", "PUT", "DELETE", "COPY", "MOVE", "LOCK", "UNLOCK" };
 
 			foreach (string verb in verbsAllowed)
@@ -37,6 +37,12 @@ namespace WebDAVSharp.Server.MethodHandlers {
 			foreach (string verb in verbsPublic)
 				context.Response.AppendHeader("Public", verb);
 
+			//tell MS Office specifically: yes, this is a WebDAV Server, and yes, we want you to use WebDAV to edit documents
+			//see. https://msdn.microsoft.com/en-us/library/cc250217.aspx
+			//and: http://stackoverflow.com/questions/40460818/ms-office-opens-documents-readonly-with-webdav
+			// or: https://answers.microsoft.com/en-us/msoffice/forum/msoffice_word-mso_winother/office-opens-documents-readonly-with-webdav/a1a6dbb6-4041-41a6-9701-8c70343da6ce 
+			context.Response.AppendHeader("MS-Author-Via", "DAV");
+
 			// Sends 200 OK
 			context.SendSimpleResponse();
 		}