4

Possible Duplicate:
HttpWebResponse: closing the stream

Using ASP.NET is it possible to make a request and get only response headers? I have to do a request to a big file, but I only need the response headers, i dont care about the content of the file.

I would like to know if there is something similar to get_headers from php (http://php.net/manual/en/function.get-headers.php).

Community
  • 1
  • 1
Cleiton
  • 17,663
  • 13
  • 46
  • 59

1 Answers1

4

I'm not sure how to do this natively, but at a minimum, you could use a custom HTTP handler (ASHX) file to create the headers you need, and return nothing else in the response.

Update:

If you set WebRequest.Method = "HEAD" then the server should automatically only return the Headers. This is according to W3.

davisoa
  • 5,407
  • 1
  • 28
  • 34