Hosting Web Service in Console Application using Nancy

This tutorial outlines basic steps needed to run a web map service using a console application based on Nancy.

Suppose you have a project file Bremen.msnpx (see Examples) with your custom map styles. The steps given below describe how to publish this map:

Step 1 Open folder ..\MapSurfer.NET\2.0\Web\Nancy\Self-Hosting. In this folder, you find MSNNancySH.exe application which we are going to run.

Step 2 Create a temp directory (for example, C:\Temp\MSNWS1)

Step 3 In this folder, create a file named mymap.config. Edit this file by adding the following (see also MSNNancySH.exe.config as a template):

<?xml version="1.0" encoding="utf-8"?>
       <supportedRuntime version="v4.0" sku=".NETFramework,Version=v4.5"/>

    <!-- The uri that the host will listen to. -->
    <add key="Nancy.Uri" value="http://localhost:8001"/>

    <!-- MapSurfer.NET version -->
    <add key="MapSurfer.Version" value="2.0"/>

    <!-- MapSurfer.NET installation path. This parameter should be used when MapSurfer.NET was not installed for everyone on the current machine and the service runs under the user which has not installed the framework. If this parameter is active then the parameter MapSurfer.Version is not taken into account.  -->
    <!--   <add key="MapSurfer.InstallPath" value="Your path" /> -->

    <!-- Map service name -->
    <add key="MapSurfer.ServiceName" value="MapSurfer.NET Web Map Service"/>
    <!-- Map service log file name -->
    <add key="MapSurfer.ServiceLogFileName" value="C:\Temp\MSNWS1\ServiceLog.txt"/>
    <!-- Map service settings file name -->
    <add key="MapSurfer.ServiceSettingsFileName" value="C:\Program Files\MapSurfer.NET\2.0\Web\Config\Service1.msnwss"/>

Step 4 Open C:\Program Files\MapSurfer.NET\2.0\Web\Config\Service1.msnwss file, change elements ConfigFileName and LogFileName as follows:

<?xml version="1.0" encoding="utf-8"?>
<WebServicesSettings xmlns:xsd="" xmlns:xsi="">
     <Description />
     <ConfigFileName>C:\Program Files\MapSurfer.NET\2.0\Web\Config\\tms_config.xml</ConfigFileName> <- Set full path
     <LogFileName> C:\Temp\MSNWS1\Logs\ErrorLog_{0}.txt</LogFileName> <- Set full path
     <LogLevel>Error</LogLevel> <- to log more events use Verbose instead of Error.
     <ServiceName>WMTS Server</ServiceName>

Step 5 Change the settings for TiledMap element in tms_config.xml as:

<TileMap href="http://localhost:8001/tms.ashx">      <- your port number 

Note that this file can contain several tile maps with different urls. You need to specify a href for each individual map.

Step 6 Run the command

MSNNancySH.exe -conf "C:\Temp\MSNWS1\mymap.config"

Step 7 To make sure the service is hosted correctly, open your browser and type localhost:8001/tms.ashx?x=0&y=0&z=0.