WMS problem

Topics: WinForms Controls
Mar 24 at 3:01 PM
Edited Mar 24 at 3:31 PM
Hi ! I'm trying to add a wms layer to my project and it doesn't work. I have modified the code in TiledWmsSample of sharpmap sample to :
string wmsUrl = "http://geo.weather.gc.ca/geomet/?lang=E&service=WMS&request=GetCapabilities"; 
WmsLayer layWms = new WmsLayer("WMS", wmsUrl);
layWms.Version = "1.3.0";
layWms.ContinueOnError = true;
layWms.TimeOut = 50000; //Set timeout to 5 seconds
layWms.SRID = 4326;
return map;
In the console Windows, looks like I'm having a response but my map is blank.

[DEBUG] SharpMap.Layers.WmsLayer - Beginning request
[DEBUG] SharpMap.Layers.WmsLayer - Got response
[DEBUG] SharpMap.Forms.MapBox - 2016/03/24 09:53:19: 2 - Env[-180 : 180, -103.41013824884793 : 103.41013824884793]
[DEBUG] SharpMap.Forms.MapBox - 2016/03/24 09:53:19: 2 - Env[-180 : 180, -103.41013824884793 : 103.41013824884793]

All others WMS sample code I could find and try works fine. Any quick idea ???

PS. Just to mention, the WMS link works fine in arcMap

Thanks :-)
Mar 29 at 8:55 AM
The problem is that the server returns "IMAGE/PNG" as content type whereas SharpMap's WmsLayer expects the content type string being all lowercase.
Mar 29 at 2:00 PM
Oh.. And where did you noticed that ?? I ran the code step by step trying to find something... In case it happend again !!

I guess it is not in the URL because it returns


And is it something I can fix in code to make it work ??

Thanks FObermaier...
Mar 29 at 2:17 PM
it is in this line:

You need to change it to
if (dataStream != null && myWebResponse.ContentType.ToLowerInvariant().StartsWith("image"))