开发者

C# WebClient, Only Support HTML3.2

I need to call a webpage, but have my webclient act like it doesn't support HTML4.0, but only HTML3.2.

Is it possible to do this? Perhaps with a different user-agent or some header I'm unaware of?

Thanks.

This is related to this problem:

SSRS开发者_运维知识库 2008, Force HTML3.2


The WebClient Class implements HTTP. It contains nothing related to HTML.

If the website you're retrieving serves different content depending on the HTTP "User-Agent" header, you can set this header as follows:

WebClient client = new WebClient();

client.Headers.Add("user-agent",
    "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)");

Which value you need to specify depends, of course, on the website.


WebClient has no notion of what kind of HTML it is downloading. If the site you're accessing is doing some sort of sniffing, use HttpWebRequest and set the UserAgent property to some really old browser.

You can set the User-Agent header using WebClient as well, but you have to set the header directly as there's no associated property.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜