1

I want to check content type in C#.NET.

I am accessing third party URL and based on that, I want to check its type. Just note down that, I am not getting any extension you can see in below example of PDF.

As an example below is the PDF file, URL is: "http://www.scoop.it/doc/download/aJpTLe5i6l38knVqb_gYeUR"

How do I know that above URL has a content type PDF and another e.g. is simple webpage, Even I want to know its content type.

"http://askfsis.custhelp.com/app/answers/detail/a_id/1380"

So I want to check something based on URL,

If it is an PDF, do this else if it is an webpage, do that etc. Your quickly response is much appreciated.

Thanks again,

FireAlkazar
  • 1,795
  • 1
  • 14
  • 27
  • 1
    Check this http://stackoverflow.com/questions/16416699/http-head-request-with-httpclient-in-net-4-5-and-c-sharp – FireAlkazar Dec 05 '15 at 10:22

1 Answers1

2

The only way is to send a HEAD request to the website and check the Content-Type header.

bohdan_trotsenko
  • 5,167
  • 3
  • 43
  • 70