.NET Server

Mobile WebDAV Server Sample for iOS & Android

In this article

Mobile WebDAV Server Sample for iOS & Android

This is a mobile WebDAV server sample that runs on iOS and Android on .NET Standard 2.0. It stores all data in iOS/Android file system extended attributes.

This sample provides access to the documents inside a mobile app folder. To see the documents a user opens a sample web page served by this server sample in a web browser on any machine in the local network. A user can open-edit-save documents right back to the device as well as a user can upload, download and manage documents using any WebDAV client.

Prerequisites

  • .NET Core SDK 2.0 release version.
  • To compile the sample for Android:
    • Visual Studio 2017 Preview (2) v15.3.1 Preview 1.0 or later on Windows. 
  • To compile the sample for iOS:
    • Visual Studio 2017 Preview (2) v15.3.1 Preview 1.0 or later on Windows
    • AND Visual Studio 2017 for Mac on Beta channel with Xamarin Mac agent running.

Note that iOS project can not be compiled using Visual Studio 2017 for Mac only or Visual Studio 2017 Preview on Windows only. You will need Visual Studio BOTH on Mac OS X and on Windows!

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

Running the Sample from Visual Studio

While running sample on Android is typically obvious, running on iOS requires more affords. Below we describe how to build and run the sample project for iOS.

  1. Install Visual Studio 2017 for Mac. Switch to Beta channel. Make sure you have all Visual Studio 2017 for Mac updates installed.
  2. Configure OS X to accept connections to Xamarin Mac Agent. Find more details here:
    • https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/
    • https://developer.xamarin.com/guides/ios/getting_started/installation/windows/connecting-to-mac/troubleshooting/
  3. Install Visual Studio 2017 Preview (2) or later on Windows machine. Make sure you have all Visual Studio 2017 Preview updates installed.
  4. Install .NET Core SDK 2.0 release version. The .NET Core 2.0 release version is required for this sample. Note that it it not installed by Visual Studio. 
  5. Download solution from NuGet using following command: 
    > nuget install WebDAV.Server
    You can also find solution in samples on GitHub and in samples provided with IT Hit WebDAV Server Engine for .NET SDK in the download area.
  6. Open a solution in Visual Studio 2017 Preview (2) or later on Windows. 
  7. Connect to Xamarin Mac Agent on OS X, see links above for more details.
  8. Set the iOS project as stat-up project in a project context menu if not set. Run the iOS project. Depending if you have iOS emulator or iPhone/iPad selected in Visual Studio the application will start and with WebDAV server running.Note! Your WebDAV server on your iOS device/emulator has an IP address of the Mac OS X machine. The port is specified in ListenerPrefix field in appsettings.webdav.json file (3335 by default).
  9. Open a web browser on any machine on the network and navigate to the WebDAV server. On OS X running the Xamarin Max Agent you can use localhost to access the server: http://localhost:3335. On any other machine on the network including on the one running VS 2017 Preview (2) on Windows, use the OS X machine IP address, for example: http://192.168.1.2:3335/

During first start the application creates a sample folders and files hierarchy in the application documents folder, under \App_Data\WebDAV\Storage\ folder, so you can browse and edit documents as well as upload, download and manage hierarchy with a WebDAV client. The sample web page provided with a project contains WebDAV Ajax Library, which is used to list documents and open documents for editing from a web page. The application creates log files in application documents folder, under \App_Data\WebDAV\Logs\.

See Also:

Next Article:

Running the WebDAV Samples