AnsweredAssumed Answered

ITHit.WebDAV.Client: The server committed a protocol violation: Section=ResponseStatusLine

Question asked by mathias.lin on Aug 11, 2016
I have a C# application where I upload a certain folder and file structure to a remote WebDav server (Alfresco repository) via the ITHit WebDav Client library. It's a couple of hundred of files (pdf, txt, doc, etc.) and subfolders.

Most of them can be uploaded just fine, but for some documents (and always the same whenever I run my code), I get an error message:

An unhandled exception of type 'ITHit.WebDAV.Client.Exceptions.WebDavException' occurred in

Additional information: The server committed a protocol violation..

The error occurs either at the point when I try to upload a file (in particular at the folder.CreateResource(…) line):

IFolder folder = …
ITHit.WebDAV.Client.IResource wdFileDestination =

or sometimes when I just want to check whether a resource exists on the remote server:

if (folder.ItemExists(dirName))

It seems that something is wrong with the response of the WebDav/Alfresco server, however assuming that I am not able to change the server response, I must handle it on client-side.

I googled for it and already found something about a flag named useUnsafeHeaderParsing, but it did no help so far.

I already added a section

<httpWebRequest useUnsafeHeaderParsing="true"/>

in my App.config

<?xml version="1.0" encoding="utf-8"?>
    <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5.2" />
    <assemblyBinding xmlns="urn:schemas-microsoft-com:asm.v1">
        <assemblyIdentity name="Newtonsoft.Json" publicKeyToken="30ad4fe6b2a6aeed" culture="neutral" />
        <bindingRedirect oldVersion="" newVersion="" />
      <httpWebRequest useUnsafeHeaderParsing="true"/>

as recommended here: C#: Handling WebClient "protocol violation" (12 upvotes) or here The server committed a protocol violation. Section=ResponseStatusLine ERROR (70 upvotes).

I also added a method to my code and enabled it via code as well (after just adding it to App.config did not help):


with the method as defined here:

Seems that the ITHit WebDav client ignores this flag.

Maybe there is something that can be done on the ITHit Webdav client side, but I have not yet found anything useful in the documentation ( yet. Has anyone had this problem before as well, especially in combination with the ITHit WebDav library that I am using.

Or does maybe anyone from the Alfresco community know about this protocol violation problem on Alfresco side?

By the way: I can upload the very same files with any other WebDav client (Windows Explorer, NetDrive, etc.) to that particular WebDav/Alfresco server without problems, just happens in my C# code.

(Originally posted on StackOverflow: