How to check if a HttpWebResponse returns a file or a page

163 Views Asked by At

How to distinguish if a response is a HTML or a file? For example, if I request an HTML file from a server(which is built based on SharePoint), the response.ContentType is 'text/html'.

So how to check if the server returns a file or a page? Should I check ContentType property?

Thanks in advance!

1

There are 1 best solutions below

0
Maarten On

All sharepoint pages will have a charset defined with the contenttype. Additionally, no SharePoint pages have a filetype of .htm/.html. For binary file types (other than media and txt) will typically come back as application/octet-stream.