HttpStatus and DownloadData

守給你的承諾、 提交于 2019-12-06 20:39:00

问题


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);

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?


回答1:


The image data would be in RestResponse.RawBytes



来源:https://stackoverflow.com/questions/10346901/httpstatus-and-downloaddata

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!