简体   繁体   中英

How do I get an HttpWebResponse for “200 OK”?

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?

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.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM