I know how to capture the HTTP response (in the form of an HttpWebResponse
) in case of an error , but how do I do this when the method returns 200 OK? I'd like to handle all the responses uniformly.
// IService.cs
public async Task Ping();
// Client.cs
public static void ReactToHttpResponse(HttpWebResponse res)
{
// Play with the http response ...
}
await service.Ping(); // => 200 OK, on the wire
ReactToHttpResponse(/* ??? */) // How to capture the HttpWebResponse?
Or should I be capturing a different response class?
Does the status code property help?
http://msdn.microsoft.com/en-us/library/system.net.httpwebresponse.statuscode.aspx
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.