简体   繁体   中英

How do I know content type in C#.NET for an URL?

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 eg 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,

唯一的方法是将HEAD请求发送到网站并检查Content-Type标头。

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM