This project is read-only.

DotSpatial &

Mar 22, 2012 at 4:42 AM

Good morning

I have been developping several WinForms applications using MapWinGIS and with DotSpatial.

I need now to set up a webmapping application using and would really like to continue using DotSpatial for its convenience targeting SQL Server spatial data.

I saw on your website home page that DotSpatial has been developped to display a map in a .NET Windows Forms or Web application but unfortunately, after several tries using VS 2010 and the dotspatial extended stable library, i didn't succeed getting any map in my page.

In VS2010 with .net 4 framework, I tried to add references or to add items in the toolbox but no DotSpatial tools appears while for a WinForm, it works perfectly.

Anyone could give some directions/exemples in order to set up a web DotSptial application?

Thanks in advance for your help.


Mar 22, 2012 at 4:42 PM

Very briefly, you can download the source and then check DotSpatialWeb.sln for an example. has been hosting a demo.

Mar 23, 2012 at 5:15 AM
Edited Mar 23, 2012 at 5:16 AM

Thanks Mudnug

Just downloaded the source and found the DotSpatial.Webcontrols in it.

First question, why is this DLL not available in the latest 1.1 download?


Secondly, I used the DEMOWeb example to set up a small application in (Sorry, more confident with that language).

I added all DotSpatial references (Analysis, Compatibility, Controls, Data, Data.Forms, Extensions, Modeling, Modeling.Forms, projections, projections.Forms, Serialization, Symbology, Symbology.Forms, Topology), add relevant shape files, images as new items in the solution Explorer, then add the controls in the toolbox using DotSpatial.WebControls.Dll.

Then I wrote the following code for the aspx:


<%@ Page Title="Home Page" Language="vb" AutoEventWireup="false"

   CodeBehind="Default.aspx.vb" Inherits="WebApplication1._Default" %>

<%@ Register Assembly="DotSpatial.WebControls" Namespace="DotSpatial.WebControls"

   TagPrefix="cc1" %>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "">

<html xmlns="">

<head id="Head1" runat="server">




   <form id="form1" runat="server">


       <div id="LegDiv" style="position:absolute; left:3px; top:3px; bottom:3px; width:230px; border:1px solid black; overflow: auto;">

       <cc1:WebLegend ID="WebLegend1" runat="server" Width="100%" Font-Size="10pt" >

               <SelectedNodeStyle BackColor="#33CCFF" BorderColor="#000099" />


           <asp:ImageButton ID="ImageButton1" runat="server" ImageUrl="~/Ref.gif"

                 style="position:absolute; right:3px; top:3px; bottom:3px; left: 203px;" /> 


           <div id="Div1" style="padding:3px; position:absolute; left:236px;top:3px; right:3px; height:33; border: 1px solid black;">

               <cc1:WebToolBar ID="WebToolBar1" runat="server" />


       <div id="Web" style="position:absolute; left:236px;top:36px; right:3px; bottom:3px; border: 1px solid black">

           <cc1:WebMap ID="WebMap1" runat="server" />







 and this one for the CodeBehind:

Imports System.Collections.Generic

Imports System.Linq

Imports System.Web

Imports System.Web.UI

Imports System.Web.UI.WebControls

Imports DotSpatial.MapWebClient

Imports DotSpatial.Projections

Imports DotSpatial.Data

Imports DotSpatial.Controls

Imports DotSpatial.Symbology

Imports System.Drawing

Imports System.Net


Public Class _Default

   Inherits System.Web.UI.Page

   Protected Sub Page_Load(ByVal sender As Object, ByVal e As EventArgs)

       If Not IsPostBack Then


           WebToolBar1.WebMapID = "WebMap1"


           WebLegend1.WebMapID = "WebMap1"

       End If

   End Sub

   Private Sub CreateMap() 

       Dim BasePath As [String] = Server.MapPath("~\Shape")

       WebMap1.Projection = KnownCoordinateSystems.Projected.World.WebMercator

       WebMap1.MapViewExtents = New Extent(-20037508.342789, -20037508.342789, 20037508.342789, 20037508.342789) 

       Dim client As New WebMapClient() 

       Dim WMT1 As New WMTClient()


       Dim WMSServerWMS0 As String = ""

       Dim WMS0 As New WMSClient() 


       WMS0.CRS = "EPSG:3857"

       WMS0.Projection = KnownCoordinateSystems.Projected.World.WebMercator 

       Dim WMSServerWMS1 As String = "" 

       Dim WMS1 As New WMSClient() 


       WMS1.CRS = "EPSG:3857"

       WMS1.Projection = KnownCoordinateSystems.Projected.World.WebMercator 




       WebMap1.Back = client 

       Dim CountriesLayer As IMapFeatureLayer = DirectCast(WebMap1.AddLayer(BasePath & "\10m_admin_0_countries.shp"), IMapFeatureLayer)

       Dim SymbCountries As New PolygonSymbolizer(Color.FromArgb(0, 191, 0))


       SymbCountries.OutlineSymbolizer = New LineSymbolizer(Color.Magenta, 1)

       CountriesLayer.Symbolizer = SymbCountries 

       Dim Graticules30Layer As IMapFeatureLayer = DirectCast(WebMap1.AddLayer(BasePath & "\10m_graticules_30.shp"), IMapFeatureLayer)

       Dim SymbGratitules30 As New LineSymbolizer(Color.Red, 1)

       Graticules30Layer.Symbolizer = SymbGratitules30 

       Graticules30Layer.IsVisible = False 

   End Sub

End Class  

Everything seems OK, no errors, no complains but when i run the code, i got an empty page....Nothing in the legen, in the map or in the toolbar, only the black lines of the divs...

 I tried to run the DEMOWEB but got an "Unable to connect to the remote server" WebException...

Really frustrating. Could it be related to this DotSpatial. MapWebClient since it does not appears anywhere... Any ideas? What am i missing? 

Thanks for help


Mar 23, 2012 at 1:45 PM
Edited Mar 23, 2012 at 1:45 PM

You have tu add an ImageHandlr.ashx at your source code (you can copy them from demoweb).

This ashx get the buffer of the image from the cache of the server and put them in the flux of the page.

In a more advanced version I think would be useful inser the "ashx" name as a properties of the controls.

If you use the control in a public site would be nice you link them here so we can see the control "in action".


Mar 26, 2012 at 12:54 AM

Thanks a lot Tommi

With the ImageHandler, it finally works in my VB.Net test application. The initial problem i had with "Unable to connect to the remote server" was due to WMS connection.

Still have some issues with Site.Master pages but will find out.

Will come back to you if i had any questions about the WebControls, but it looks really impressive.
Keep continue developing it, it would be a great asset for DotSpatial to works on ASP pages.


Mar 27, 2012 at 10:19 AM

Have you some sample of using SQL Server spatial data?

I have need of implement them...



Aug 3, 2013 at 9:14 PM
Edited Aug 3, 2013 at 9:14 PM
Hi, I'm new developing GIS applications and I would like to know where can I download the DotSpatial.Webcontrols.dll?, because I've searched on this website without results.

Thanks for the help,

Feb 24, 2014 at 9:41 PM
Hello Tommy have you been able to implement this using SQL Server spatial data? I too need to implement this using spatial data and not shapefile. Thanks.