的HTTPStatus和DownloadData [英] HttpStatus and DownloadData
本文介绍了的HTTPStatus和DownloadData的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想下载一个文件(影像)使用RestSharp的DownloadData方法
I'm trying to download a file (an image) with RestSharp using the DownloadData method
var client = new RestClient(baseUrl);
var request = new RestRequest("GetImage", Method.GET);
var response = client.DownloadData(request);
这工作得很好,但如果请求返回一个错误,我无法看到的HTTPStatus代码。
This works fine, but if the requests returns an error I cannot see the HttpStatus code.
我可以做一个请求并检查其状态:
I could make a Request and check the status:
var client = new RestClient(baseUrl);
var request = new RestRequest("GetImage", Method.GET);
var response = client.Execute(request);
var status = response.StatusCode;
但我无法从内容属性的形象。
But then I cannot get the image from the Content property.
我我失去了一些东西明显?
I'm I missing something obvious?
推荐答案
图片数据将是 RestResponse.RawBytes
这篇关于的HTTPStatus和DownloadData的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文