This project is read-only.


The project will not be maintained at CodePlex anymore. If you have any issues or questions about the Portable WebDAV Library, please visit the GitHub project site

This is just a quick overview of the Portable WebDAV Library with some sample code.

A full (online) documentation of the library can be found here:
Portable WebDAV Library online documentation

There are two levels of abstractions included in this library: A low level abstraction (class WebDavClient) which supports direct access to a WebDAV server and a higher level of abstraction (class WebDavSession) which hides most of the direct WebDAV communication and provides an easy access to WebDAV resources.


The WebDavSession should be sufficient for most use cases regarding WebDAV access. It provides a high level of abstraction and hides most of the WebDAV specific details (like sending or receiving XML content strings) and supports an easy access to WebDAV servers.

See the following code which uses a WebDavSession to retrieve the content of a folder:
// Specify the user credentials and use it to create a WebDavSession instance.
var credentials = new WebDavCredential("UserName", "MyPassword");
var webDavSession = new WebDavSession(@"http://www.myserver/webdav/", credentials);
var items= await webDavSession.ListAsync(@"myfolder/");

foreach (var item in items)


When the WebDavSession is not sufficient for specific operations, there is also a low level WebDAV access: WebDavClient. This class inherits from System.Net.Http.HttpClient and offers all WebDAV specific operations in the same style as the HttpClient. By using WebDavClient, you can use all of the WebDAV operations specified in RFC 4918. The use of WebDavClient is recommended for users who are familiar with the WebDAV speficifaction.

See the following code which uses a WebDavClient to retrieve the content of a Folder (the same as done above with a WebDavSession):
// Specify the user credentials and pass it to a HttpClientHandler.
var credentials = new WebDavCredential("UserName", "MyPassword");
var httpClientHandler = new HttpClientHandler();
httpClientHandler.Credentials = credentials;
httpClientHandler.PreAuthenticate = true;

// Use the HttpClientHandler to create the WebDavClient.
var webDavClient = new WebDavClient(httpClientHandler);

// Create a PropFind object with represents a so called allprop request.
PropFind pf = PropFind.CreatePropFindAllProp();
var response = await webDavClient.PropFindAsync(@"http://www.myserver/webdav/myfolder/", WebDavDepthHeaderValue.Infinity, pf);

// You could also use an XML string directly for use with the WebDavClient.
//var xmlString = "<?xml version=\"1.0\" encoding=\"utf-8\"?><D:propfind xmlns:D=\"DAV:\"><D:allprop /></D:propfind";
//var response = await webDavClient.PropFindAsync(@"http://www.myserver/webdav/myfolder/", WebDavDepthHeaderValue.Infinity, xmlString);

// Use the WebDavResponseContentParser to parse the response message and get a MultiStatus instance (this is also an async method).
var multistatus = await WebDavResponseContentParser.ParseMultistatusResponseContentAsync(response.Content);

// Now you can use the MultiStatus object to get access to the items properties.
foreach (var responseItem in multistatus.Response)


The Portable WebDAV Library also supports WebDAV locking.
When using a WebDavClient, the locking has to be managed by the calling code, i.e. the handling of lock tokens etc.
Using a WebDavSession makes WebDAV locking pretty easy, because the WebDavSession handles all the locking mechanism by itself. As an example: When the WebDavSession was used to lock a folder, all subsequent operations affecting the locked file or folder, no lock specific details have to be provided (e.g. you do not have to specify a lock token). This is all handled internally in the WebDavSession itself.

For example code demonstrating locking with WebDavClient or WebDavSession, see the documentation of these classes.

WebDAV object model

Most communication regarding WebDAV is realized with XML strings sent or received in the content of requests or responses. The library contains the WebDAV object model implemented in classes/enums, so there is no need to build up or parse any XML strings directly. Of course you can also use XML strings directly.


For development, you will need:

Unit tests

The solution contains unit tests (testing single units of the library), but also unit integration tests, which will test the library against a specific WebDAV server (e.g. a local IIS web server with WebDAV enabled).

Important: In order to run the unit integrations tests, information about a specific WebDAV server have to be provided in a configuration file. This has to be a file named "TestConfiguration.txt" located in the unit integration test project's output folder. This file has to contain exactly three lines:
  • The user name
  • The password
  • The URL of a valid WebDAV server folder

If this configuration file is not present, all unit integration tests will fail!

Last edited Sep 5, 2016 at 1:54 PM by decatec_de, version 10