The link below is an image URL where the extension has been stripped. I assume this is being done with content negotiation tools. I know that it’s a GIF having viewed the HTML meta data with Firebug. What I would like to know is a simple way working in C# on .NET, how would I get the file type of this URL?
http://ep.yimg.com/ca/I/yhst-20493720720238_2066_63220718
With most image URLs it’s easy. One can use string functions to find the file type in the URL.
Ex. /imageEx.png
You’re going to have to make an HTTP HEAD request, and then check the Content-Type on the response. I can’t recall whether
System.Net.HttpWebRequestsupports HEAD requests, but that would be the place to start.Alternatively, you could perform a full GET request, but that could have performance implications if all you need to know is Content-Type.