try using WebClientWebClient client = new WebClient();
client.DownloadStringCompleted += new DownloadStringCompletedEventHandler(this.Client_DownloadStringCompleted);
string configUrl = string.Format("{0}{1}", this.Url, "?f=json");
client.DownloadStringAsync(new Uri(configUrl)); then deserialise the json result.public static T DeserializeJson<T>(string jsonString)
{
using (MemoryStream memoryStream = new MemoryStream(Encoding.UTF8.GetBytes(jsonString)))
{
try
{
DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
T returnObject = (T)serializer.ReadObject(memoryStream);
return returnObject;
}
catch (Exception e)
{
////Logging.Log.Error("Deserialize json string");
return default(T);
}
}
}you will need to set up a class that defines the DataContract in the returned json, below is an example for the whole service (MapServer part of url without the layer index)....using System.Runtime.Serialization;
namespace Your.Namespace
{
[DataContract]
public class DocumentInfo
{
[DataMember]
public string Title { get; set; }
[DataMember]
public string Author { get; set; }
[DataMember]
public string Comments { get; set; }
[DataMember]
public string Subject { get; set; }
[DataMember]
public string Category { get; set; }
[DataMember]
public string Keywords { get; set; }
[DataMember]
public string Credits { get; set; }
}
[DataContract]
public class ExtentConfig
{
[DataMember]
public double? xmin { get; set; }.....
[DataContract]
public class ServiceConfig
{
[DataMember]
public DocumentInfo documentInfo { get; set; }
[DataMember]
public string serviceDescription { get; set; }
[DataMember]
public string mapName { get; set; }
[DataMember]
public string description { get; set; }
[DataMember]
public string copyrightText { get; set; }....
to call the desrialiser would be ServiceConfig deserialisedConfig = Serializer.DeserializeJson<ServiceConfig>(e.Result);
where e.Result is the DownloadStringCompletedEventArgs parameter of your DownloadStringCompletedEventHandler on the WebClient set at the beginningshould be enough for you to work out how to do it, there are other ways of doing ithope this helpsregardschris