簡體   English   中英

如何獲得“200 OK”的HttpWebResponse?

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

我知道如何在出現錯誤的情況下捕獲HTTP響應(以HttpWebResponse的形式),但是當方法返回200 OK時如何執行此操作? 我想統一處理所有的回復。

// 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?

或者我應該捕獲不同的響應類?

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM