Using the WebRequest class to query a map image from the WMS servlet

  • Load a map image in C#

    To load a WMS image in C#, you can use the WebRequest class and initialize a System.Drawing.Image object from the response string.

public static void TestWebRequest()
    var request = WebRequest.Create(
        "&format=image/png&version=1.1.1&layers=xmap-plain&srs=EPSG:505456&styles=&xtok=<your token>");
    var response = request.GetResponse();
    var bitmap = System.Drawing.Image.FromStream(response.GetResponseStream());