I need some way to check the size of a download without having to download the entire file. I am using C# and the System.Net.WebClient to do the downloads.The check needs to run in a asp.net webservice.
Thanks
Use HTTP method HEAD to retrieve Content-Length: header.
HEAD / HTTP/1.1
Host: www.example.com
HTTP/1.1 200 OK
Date: Wed, 18 Mar 2009 11:21:51 GMT
Server: Apache/2.2.3 (CentOS)
Last-Modified: Tue, 15 Nov 2005 13:24:10 GMT
ETag: "b80f4-1b6-80bfd280"
Accept-Ranges: bytes
Content-Length: 438
Connection: close
Content-Type: text/html; charset=UTF-8
Make a HEAD (rather than GET or POST) request to just get the response headers, this should include the content-length header with the information you need.
You can also use the HTTP RANGE header to download only the stuff you want.
It would be really simple to build a HttpRangeStream that supports seek and read on a remote HTTP resource, if the remote server is HTTP 1.1 and correctly supports RANGE headers.