[英]RestSharp - How do I get the numerical http response code?
我正在为 C# 使用RestSharp HTTP 客户端库。
我将如何检索实际的数字 http 响应代码? 我不仅没有看到包含数字代码的属性,而且我什至在 headers 集合中也没有看到它。
只需从RestResponse对象中获取 StatusCode 属性并将枚举值转换为 int。
RestResponse response = client.Execute(request);
HttpStatusCode statusCode = response.StatusCode;
int numericStatusCode = (int)statusCode;
Assert.Equal(200, (int)response.StatusCode);
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.