ASP.NET WebDAV Server Example with File System Back-end, C#
WebDAVServer.NtfsStorage example is a fully functional Class 2 WebDAV server that stores all data in the file system. It utilizes NTFS Alternative Streams to store locks and custom properties and runs as ASP.NET application in IIS or IIS Express. This example is preconfigured to use Basic authentication as well as it has Quota implementation and can manage file attributes used by Windows Explorer.
To run this example, you will need:
ASP.NET 4.5 or later on Windows Server 2012, Windows Server 2008, Windows 10, Windows 8, Windows 7 or Windows Vista.
NTFS file system.
For simplicity of evaluation Visual Studio 2013 or Visual Studio 2012 are recommended. This sample does not support Visual Studio 2010.
IMPORTANT! 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.NtfsStorage example is installed to C:\Users\<UserName>\Documents\IT Hit\WebDAV Server Engine\vX.X.X\Samples\WebDAVServer.NtfsStorage\ folder.
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 root folder of the WebDAVServer.NtfsStorage example (\Samples\WebDAVServer.NtfsStorage\).
Running Example from Visual Studio
If you have Visual Studio, the simplest way to run the sample is to run it from Visual Studio. In this case, you do not need to configure the web application in IIS.
Note that in case you are using Visual Studio 2010, SP 1 and IIS Express are highly recommended. After opening the project in Visual Studio 2010 switch to IIS Express using ‘Use IIS Express’ project menu.
The files are stored in file system in \Samples\WebDAVServer.NtfsStorage\App_Data\WebDav\Storage\ folder. You can change the storage location in RepositoryPath tag in web.config.
The WebDAVServer.NtfsStorage example is using Basic authentication. For the sake of simplicity, credentials are stored in web.config file.
Important! Microsoft Office 2010 and later versions, as well as Windows Shell (Web Folders / mini redirector) requires secure SSL connection when used with Basic authentication. Microsoft Office 2010 will fail to open a document via an insecure connection with Basic authentication. For a workaround please see this article: You cannot open Office file types directly from a server that only supports Basic Authentication over a non-SSL connection with Office 2010 applications.
WebDAVServer.NtfsStorage example implements Quota standard. The implementation reads used and free space on the hard drive where WebDAV server is running and returns this data for each folder. Such implementation may not provide the best performance and is for demo purposes only. Below you can see Ajax Browser displaying quota:
The Project Classes
On the diagram below you can see the classes in WebDAVServer.NtfsStorage project.
To adapt the sample to your needs, you will modify these classes to read and write data from and into your storage. You can find more about this in Creating a Class 1 WebDAV Server and Creating Class 2 WebDAV Server article as well as in the class reference documentation.