.NET Server

WebDAV Server with Versioning Example, C#

In this article

WebDAV Server with Versioning Example, C#

The WebDAVServer.DeltaV example is a Class 2 server with DeltaV versioning support. This example is an extension of WebDAVServer.SqlStorage example, but unlike SqlStorage Example, the DeltaV example runs as HttpListener console application or Windows Service. The WebDAVServer.DeltaV example is a fully functional WebDAV server that can be used to open, edit and save Microsoft Office documents directly on the server, without download/upload steps. You can use it to access documents using Microsoft Mini-Redirector/Web Folders, Mac OS X Finder or any other WebDAV client.

Prerequisites

To run this example, you will need:

  • .Net Framework 4.5 or later on Windows Server 2012, Windows Server 2008, Windows 10, Windows 8, Windows 7 or Windows Vista.
  • Microsoft SQL Server Express LocalDB or Microsoft SQL Express or Microsoft SQL Server 2014 / 2012 / 2008 / 2005.

Because this sample uses TAP interfaces you need .NET 4.5 or later to run it. If you need to support .NET 4.0 or 3.5 use the 'ASP.NET CalDAV/CardDAV Server Application' wizard or other WebDAV wizards in Visual Studio and select .NET 4.0 or .NET 3.5 in a New Project dialog.

Installation and Configuration

By default, WebDAVServer.DeltaV example is installed to C:\Users\<UserName>\Documents\IT Hit\WebDAV Server Engine\vX.X.X\Samples\WebDAVServer.DeltaV\ folder.

The port and on which the service will be running is specified in app.config file in ListenerPrefix tag. By default, the server will listen to all hostnames. Edit the value of this tag to run your server on a specific port and hostname.

Setting the License

To run the example, you will need a valid IT Hit WebDAV Server Engine License. You can download the license here. Note that the Engine is fully functional with a trial license and does not have any limitations. The trial license is valid for one month and the engine will stop working after this. You can check the expiration date inside the license file.
Place the license file in the bin folder of the DelatV Example (\Samples\WebDAVServer.DeltaV\bin\).

Database and Logs location

The database and logs of this example are located under \Samples\WebDAVServer.DeltaV\App_Data\ folder. The App_Data folder is named this way purely for consistency across all samples. Unlike with ASP.NET, App_Data folder name does not play any role for HttpListener.

If you have the Microsoft SQL Server LocalDB installed, the database will attach automatically when you run the sample. The database is located in \Samples\WebDAVServer.DeltaV\App_Data\WebDav\DB\.

In case you do not have Microsoft SQL Server LocalDB installed you will need to create the database manually and update the string in app.config file. You can find the database script in \Samples\WebDAVServer.DeltaV\DB.sql file.

Running Example as a Console Application

To start the example, you can execute the exe file in \bin\ folder. For the sake of configuration simplicity, this example requires administrative permissions when run as a console app. 
As soon as you run the executable it will immediately open the web browser with a default page.

Running Example as a Windows Service

To register the WebDAVServer.DeltaV example as a Windows Service, execute the following command:

C:\Windows\Microsoft.NET\Framework\v2.0.50727\InstallUtil.exe /i “C:\Program Files (x86)\IT Hit\WebDAV Server Engine\v3.5.1122\Samples\WebDAVServer.DeltaV\bin\WebDAVServer.DeltaV.exe”

Then open Services MMC, find the “DeltaV WebDAV Server” service and start it.

Now open the web browser and go to http://localhost:3458 .

Using with Microsoft Office and other Applications.

By default, the WebDAV Versioning Example is using CheckOutUnlockedCheckIn auto versioning mode. You can see how this mode works on the diagram in the Creating DeltaV WebDAV Server article. The idea of this mode is to minimize an amount of versions automatically created when the file is being saved. This works especially well with applications that lock WebDAV files such as Microsoft Office.

In this mode, the new version is created when the file is being unlocked by Microsoft Office, usually when the user closes the document. Between Lock and Unlock no new versions are created, Lock/Unlock acts as a Check-out/Check-in operations. For applications that do not lock files, the new version is created each time the file is being saved.

Ajax Browser Versions list

The Example Project Classes

On the diagram below you can see the classes in WebDAVServer.DeltaV project.

The diagram of the classes in DeltaV project

You can find more about building a server with versioning in Creating WebDAV Server with Versioning Support article. You may also want to read Creating a Class 1 WebDAV Server and Creating Class 2 WebDAV Server articles.

How things get stored – overview of the SQL Back-end

The database consists of 5 entities as depicted in the figure below. 2 of them, Property and Lock, are identical to the tables found in SqlStorage example. The Item table contains additional fields: CreatorDisplayName, Comment, CheckedOut, AutoVersion and AutoCheckedOut.

WebDAV Server with Versioning (DeltaV) database diagram

Version table

The Version table contains file versions. If versioning is enabled each file contains at least one version in this table.

VersionProperty table

The VersionProperty table contains a snapshot of the properties that was attached to the item when this version was created.

 

 See Also:

Next Article:

Mobile WebDAV Server Sample for iOS & Android