how to deserialize if response is html

Solutions on MaxInterview for how to deserialize if response is html by the best coders in the world

showing results for - "how to deserialize if response is html"
Philipp
29 Mar 2019
1        HttpClient client = new HttpClient();
2        client.BaseAddress = new Uri(url);
3        client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
4        HttpResponseMessage response = client.GetAsync(url).Result;
5
6        if (response.IsSuccessStatusCode)
7        {
8            var result  = response.Content.ReadAsStringAsync().Result;
9            var s = Newtonsoft.Json.JsonConvert.DeserializeObject(result);
10            return "Success";
11        }
12        else
13        {
14            return "Fail";
15        }
16