Cross-platform ASP.NET Core WebDAV Server Sample with File System Back-End
This is a cross-platform WebDAV server sample with a 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 the case of Windows or in Extended Attributes in the 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.
This sample is provided as part of the IT Hit WebDAV Server Engine v5 and later and is published to GitHub and to NuGet. For a legacy file system storage sample provided with IT Hit WebDAV Server Engine v4.5 based on HttpHandler see this article.
- .NET Core 3.1 or later version on Windows, OS X or Linux.
- A 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:
- 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
- Install NuGet client tools: https://docs.microsoft.com/en-us/nuget/install-nuget-client-tools
- Create a project folder, for example,/WebDAVServer/, and navigate to that folder in console.
- Get the project from NuGet:
nuget install WebDAVServer.FileSystemStorage
- Navigate to the project folder, where the .scproj file is located:
- Restore dependencies:
- Build the project:
- Run the project:
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 an edit button/link for opening each file from the server using WebDAV Ajax Library. You can also run the 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 the 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
By default, files are stored in the file system in \App_Data\WebDav\Storage\ folder. You can change the storage location in RepositoryPath in appsettings.webdav.json. You can specify either an absolute or relative path.
Locks and Custom Properties Location
By default locks and custom properties are stored in Alternate Data Streams (on Windows) or in Extended Attributes (on Linux and Mac), together with a file. If Alternate Data Streams/Extended Attributes are not supported, this sample will try to store locks and custom properties in the system temp folder.
To specify a location where the locks and custom properties should be stored specify the folder path in the AttrStoragePath in appsettings.webdav.json. Every attribute will be stored in a separate file under this folder in this case.
// "AttrStoragePath": "App_Data/WebDAV/Attributes/"
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.
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 an insecure connection with Basic authentication. For a workaround please see the following articles:
- In the 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 the 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.