try
{
HttpWebRequest req = WebRequest.Create(UnitInfoServiceUrl) as HttpWebRequest;
req.Credentials = new NetworkCredential("", "");
req.KeepAlive = false;
string result;
using (WebResponse resp = req.GetResponse())
{
using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
{
result = reader.ReadToEnd();
}
}
}
catch (WebException e)
{
using (WebResponse response = e.Response)
{
HttpWebResponse httpResponse = (HttpWebResponse)response;
Response.Write(string.Format("Error code: {0}", httpResponse.StatusCode));
using (Stream data = response.GetResponseStream())
using (var reader = new StreamReader(data))
{
string text = reader.ReadToEnd();
Response.Write(text);
dynamic stuff1 = JsonConvert.DeserializeObject(text);
string Error = stuff1.ERROR;
Response.Write(Error );
}
}
}
{
HttpWebRequest req = WebRequest.Create(UnitInfoServiceUrl) as HttpWebRequest;
req.Credentials = new NetworkCredential("", "");
req.KeepAlive = false;
string result;
using (WebResponse resp = req.GetResponse())
{
using (StreamReader reader = new StreamReader(resp.GetResponseStream()))
{
result = reader.ReadToEnd();
}
}
}
catch (WebException e)
{
using (WebResponse response = e.Response)
{
HttpWebResponse httpResponse = (HttpWebResponse)response;
Response.Write(string.Format("Error code: {0}", httpResponse.StatusCode));
using (Stream data = response.GetResponseStream())
using (var reader = new StreamReader(data))
{
string text = reader.ReadToEnd();
Response.Write(text);
dynamic stuff1 = JsonConvert.DeserializeObject(text);
string Error = stuff1.ERROR;
Response.Write(Error );
}
}
}
No comments:
Post a Comment