小编use*_*164的帖子

.Net C#:从HttpWebResponse读取附件

是否可以从System.Net.HttpWebResponse读取图像附件?

我有一个url到一个生成图像的java页面.

当我在firefox中打开url时,会出现下载对话框.内容类型是application/png.似乎工作.

当我在c#中尝试这个并发出GET请求时,我检索内容类型:text/html并且没有内容处置标头.

简单代码:

HttpWebRequest request =(HttpWebRequest)WebRequest.Create(uri); HttpWebResponse response =(HttpWebResponse)request.GetResponse();

"response.GetResponseStream()"为空.

尝试使用java是成功的.

我是否必须准备webrequest或其他东西?

c# attachment httpwebrequest httpwebresponse

5
推荐指数
1
解决办法
2238
查看次数

标签 统计

attachment ×1

c# ×1

httpwebrequest ×1

httpwebresponse ×1