Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpClient StatusDescription is missing

i use the httpclient from Microsoft.Net.Http (version 2.2.22) to request some of my mvc pages. My page returns a HttpStatusCodeResult like:

 return new HttpStatusCodeResult(clientResponse.StatusCode, "Blub Blub");

With the httpclient it is not problem to call the page. But i couldn't find a way to access the statusDescription ("Blub Blub"). Is there a way to access the description? And if not, why microsoft doesn't make it accessable? By the way if i call the site from browser (Chrome) the description is shown as expected.

like image 659
Flo Avatar asked May 18 '17 11:05

Flo


1 Answers

If you use one of the methods from HttpClient such as GetAsync

(https://msdn.microsoft.com/en-us/library/hh158944(v=vs.118).aspx)

it returns an HttpResponseMessage object

(https://msdn.microsoft.com/en-us/library/system.net.http.httpresponsemessage(v=vs.118).aspx).

One of the properties of that object is ReasonPhrase which should contain the description that you sent.

like image 110
ADyson Avatar answered Oct 22 '22 02:10

ADyson