.Net C# : Read attachment from HttpWebResponse
Is it possible to read an image attachment from System.Net.HttpWebResponse?
I have an url to a java page, which generates images.
When i open the url in firefox, the download dialog appears. Content-type is application/png. Seems to work.
when i try this in c# and make a GET request i retrieve the content-type: text/html and no content-disposition header.
Simple Code:
HttpWebRequest request = (HttpWebRequest)WebRequest.Create(uri); HttpWebResponse response = (HttpWebResponse)request.GetResponse();
"response.GetResponseStream()" is empty.
A try with java was succesfull.
Do i have to prepare webrequest or something else?
You probably need to set a User-Agent header.
Run Fiddler and compare the requests.
链接地址: http://www.djcxy.com/p/45892.html