Cross-platform ASP.NET Core WebDAV Server Sample with File System Back-End

This sample is provided as part of the IT Hit WebDAV Server Engine v5 and is published to NuGet. For a legacy file system storage sample provided with IT Hit WebDAV Server Engine v4.5 based on HttpHandler see this article.

This is a cross-platform WebDAV server sample with file system back-end that stores all data in a file system and runs as ASP.NET Core web application on Windows, OS X and Linux. The sample keeps locks and custom properties in NTFS Alternate Data File Streams in case of Windows or in Extended Attributes in case of OS X and Linux. This sample is anonymous by default but is provided with sample Basic and Digest authentication middle-ware.

This sample is provided with a sample web page that demonstrates WebDAV Ajax Library integration that is used to open documents from a web page, list server content and navigate folders structure.

Prerequisites

  • .NET Core 1.0 or later version on Windows, OS X or Linux.
  • File system with Extended Attributes support: NTFS, Ext2-Ext4, HFS+, APFS, etc.

Running Sample Using Command Prompt

The instructions below describe how to install a sample from NuGet and are universal for Windows, OS X and Linux:

  1. Install .NET Core. Follow instructions on this page to install Microsoft .NET Core on Windows, OS X and Linux: https://www.microsoft.com/net/core
  2. Create a project folder, for example /WebDAVServer/, and navigate to that folder in console.
  3. Get the project from NuGet: 
    nuget install WebDAVServer.FileSystemStorage
  4. Navigate to the project folder, where the .scproj file is located:
    cd WebDAVServer.FileSystemStorage.<version>
  5. Restore dependencies:
    dotnet restore
  6. Build the project:
    dotnet build
  7. Run the project:
    dotnet run

Now your server runs on http://localhost:5000. Open the web browser with this URL and you will see the web page that lists folder content on your server and provides edit button/link for opening each file from server using WebDAV Ajax Library. You can also run Ajax Integration test to find if your server is running correctly. To upload documents, create folders, copy and move files, manage custom properties, etc you can use the Browse Using Ajax File browser button.

Setting the License

To run the example, you will need a valid IT Hit WebDAV Server Engine License. You can download the license in the product download area. 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. Download the license file and specify it's content in License field under DavEngineOptions in appsettings.webdav.json file.

You can also run the sample without explicitly specifying a license for 5 days. In this case the Engine will automatically request the trial license from IT Hit website https://www.webdavsystem.com. Make sure it is accessible via firewalls, if any. After 5 days the Engine will stop working. To extend the trial period you will need to download a license in a product download area and specify it in appsettings.webdav.json

Storage location

By default files are stored in file system in \App_Data\WebDav\Storage\ folder. You can change the storage location in RepositoryPath in appsettings.webdav.json. You can specify either absolute or relative path.

Authentication

This sample is provided with Basic and Digest authentication middle-ware. By default the authentication is disabled and the sample is anonymous. To enable Basic or Digest authentication uncomment the UseBasicAuth() or UseDigesAuth() calls inside Configure() method in Startup.cs.

For the sake of simplicity, credentials are stored in appsettings.webdav.json file.

Important! Microsoft Office on Windows and OS X as well as Windows Shell (Web Folders / mini-redirector), requires secure SSL connection when used with Basic authentication. Microsoft Office will fail to open a document via insecure connection with Basic authentication. For a workaround please see the following articles:
- In case of MS Office on Windows: You cannot open Office file types directly from a server that only supports Basic Authentication over a non-SSL connection with Office applications.
- In case of MS Office on Mac OS X: You cannot open Office for Mac files directly from a server that supports only Basic authentication over a non-SSL connection.

See Also: