Fabio D' Ovidio ha scritto: > Does MapServer 4.4.1 support .NET Framework SDK 2.0 ?
I don't know if C# MapScript works with .NET 2, but you can work both in BROWSE and *QUERY* mode using cgi. There are no threading issues except Mapserver cgi itself (I suppose). For example, using Ajax .NET (http://ajax.schwarz-interactive.de/csharpsample/default.aspx) something like this (only an idea, not complete and raw): Main .aspx page: //using dbox function setbox_handler(name, minx, miny, maxx, maxy) { document.mapserv.imgbox.value = minx + " " + miny + " " + maxx + " " + maxy; document.mapserv.imgxy.value = minx + " " + miny; //document.forms[0].submit(); <-- old form style retrieveMap(); <-- new Ajax style } ... <img id=main_image src="" width="" height=""> <input name="ref" type="image" id="referenceMap" src=""> Code behind: if(!IsPostBack) { // Register the class that will hold the methods. BorgWorX.Web.Core.Ajax.Utility.RegisterTypeForAjax(typeof (mapsrvNet.AjaxMethods), Page); } else { ... } file AjaxMethods.js: var swapMapImageTime = 1000; //offscreen images, used in preload var imgMapOff = new Image(); var imgRefOff = new Image(); var queryString; var layers; var baseUrl; var imgxy; var imgext; var mapwidth; var mapheight; var imgbox; var zoom = 0; function retrieveMap() { //recupero lista layers var childNodes = document.getElementById("layerListDiv"); layerArray = childNodes.getElementsByTagName("input"); //alert(layers.length); var i; var layersString = ""; for(i=0; i < layerArray.length; i++) { if(layerArray[i].checked == true) { layersString += "&layer=" + layerArray[i].value; } } baseUrl = document.getElementById("baseUrl").value; imgxy = document.getElementById("imgxy").value; imgext = document.getElementById("imgext").value; mapwidth = document.getElementById("mapwidth").value; mapheight = document.getElementById("mapheight").value; imgbox = document.getElementById("imgbox").value; //build url querySting = baseUrl + layersString + "&mode=browse" + "&imgext=" + imgext + "&imgbox=" + imgbox; AjaxMethods.RetrieveImage(querySting, retrieveMapImage_callback); } function retrieveMapImage_callback(res) { try { if(typeof(res.value) == 'object' && res.error == null) { imgMapOff.src = res.value.mapImgUrl; //preload image imgRefOff.src = res.value.referenceMap; setTimeout("updateImg()",swapMapImageTime); //and wait n seconds for image download } else { throw res.error.toString(); } } catch (exception) { this.status = "PROBLEMS RETRIEVING MAP !"; //alert(exception); } } function updateImg() { document.getElementById("main_image").src = imgMapOff.src; document.getElementById("referenceMap").src = imgRefOff.src; } SERVER SIDE (C#): file AjaxMethods.cs: namespace mapsrvNet { /// <summary> /// Summary description for Methods. /// </summary> public class AjaxMethods { //qui devo creare classe Map [BorgWorX.Web.Core.Ajax.AjaxMethod()] public Map RetrieveImage(string queryString) { string mapImgUrl = null; string mapwidth = null; string mapheight = null; string scalebar = null; string imgxy = null; //[center] of the image string imgext = null; string legend = null; string referenceMap = null; Map map = null; //holds all map value try { // Create a 'WebRequest' with the specified url. //if(debug)throw new Exception ("queryString: "+queryString); HttpWebRequest webRequest = (HttpWebRequest) WebRequest.Create(queryString); //webRequest.KeepAlive = false; webRequest.Timeout=10000; webRequest.Method = "GET"; // Send the WebRequest and read response HttpWebResponse webResponse = (HttpWebResponse) webRequest.GetResponse(); Stream sResponse = webResponse.GetResponseStream(); StreamReader reader = new StreamReader (sResponse); //first line is additional info from MapServer string header = reader.ReadLine(); if(header == "<HTML>") { string message = reader.ReadToEnd(); message += "\n\n\"" + header + message + "\"\n\n"; throw new Exception(message); } //actual parameters mapImgUrl = reader.ReadLine(); mapwidth = reader.ReadLine(); mapheight = reader.ReadLine(); scalebar = reader.ReadLine(); imgxy = reader.ReadLine(); imgext = reader.ReadLine(); legend = reader.ReadLine(); referenceMap = reader.ReadLine(); map = new Map(mapImgUrl, mapwidth, mapheight, scalebar, imgxy, imgext, legend, referenceMap); sResponse.Close(); reader.Close(); webResponse.Close(); } catch (Exception ex) { throw new Exception ("queryString:"+queryString+"\n\n"+ex.ToString()); } return map; } //method } //class } //namespace file Map.cs: namespace mapsrvNet { /// <summary> /// Description of Map. /// </summary> [Serializable] public class Map { public string mapImgUrl = ""; public string mapwidth = ""; public string mapheight = ""; public string scalebar = ""; public string imgxy = ""; public string imgext = ""; public string legend = ""; public string referenceMap = ""; public Map(string mapImgUrl, string mapwidth, string mapheight, string scalebar, string imgxy, string imgext, string legend, string referenceMap) { this.mapImgUrl = mapImgUrl; this.mapwidth = mapwidth; this.mapheight = mapheight; this.scalebar = scalebar; this.imgxy = imgxy; this.imgext = imgext; this.legend = legend; this.referenceMap = referenceMap; } } } file web_template.html: (u could use also xml file) [img] [mapwidth] [mapheight] [scalebar] [center] [mapext] [legend] [ref] .Map file: ... TEMPLATE "templates/web_template.html" ... U work in similar way with query templates. Bye Piero
