Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- public static T callWSGet<T>(string url, string method, bool isAuth)
- {
- T objResponse;
- var httpWebRequest = (HttpWebRequest)WebRequest.Create("http://wssommapositiva/" + url);
- httpWebRequest.ContentType = "text/json";
- httpWebRequest.Method = method;
- // Necessario per token
- if (isAuth)
- httpWebRequest.Headers.Add("X-Token", HttpContext.Current.Session["Token"].ToString());
- var httpResponse = (HttpWebResponse)httpWebRequest.GetResponse();
- using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
- {
- objResponse = JsonConvert.DeserializeObject<T>(streamReader.ReadToEnd());
- }
- return objResponse;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement