Setting WebBrowser.DocumentText - interprets as plaintext?

D

Dylan Nicholson

Hello,

I have an odd problem that only occurs on one machine, running IE 6.0
(latest SP etc.) and Windows Server 2000, .NET 2.0 SP1, whereby
setting the DocumentText property sometimes causes the text to be
interpreted as plain text rather than HTML. That is, after doing:

WebBrowser.DocumentText = new string(' ', 192) + "<html><body>Test</
body></html>"

then checking WebBrowser.DocumentText again, it's now

<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0 Transitional//EN">
<HTML><HEAD>
<META http-equiv=Content-Type content="text/html; charset=utf-8"></
HEAD>
<BODY><PRE>

&lt;html&gt;&lt;body&gt;Test&lt;/body
&gt;&lt;/html&gt;</PRE></BODY></HTML>


If the initial space padding is only 191 characters, it behaves fine!

There's other cases without this padding where the problem still
occurs, but that's the simplest to explain. I've tried upgrading
everything I can on the problem machine, but it appears to have the
latest of everything, granted that it's an old 2000 server machine.

Anyone seen anything like this before?

Dylan
 
I

Igor Tandetnik

Dylan Nicholson said:
I have an odd problem that only occurs on one machine, running IE 6.0
(latest SP etc.) and Windows Server 2000, .NET 2.0 SP1, whereby
setting the DocumentText property sometimes causes the text to be
interpreted as plain text rather than HTML. That is, after doing:

WebBrowser.DocumentText = new string(' ', 192) + "<html><body>Test</
body></html>"

If the initial space padding is only 191 characters, it behaves fine!

I believe IE performs content sniffing to figure out what kind of text
it is given. The sniffing is very simple - it just looks for <html> tag
in the first few characters of the text. I've seen this problem with
regular standalone IE, when a) a page has, say, a large comment at the
top before <html> tag, and b) the server sends an incorrect Content-Type
header, usually text/plain.
--
With best wishes,
Igor Tandetnik

With sufficient thrust, pigs fly just fine. However, this is not
necessarily a good idea. It is hard to be sure where they are going to
land, and it could be dangerous sitting under them as they fly
overhead. -- RFC 1925
 
D

Dylan Nicholson

I believe IE performs content sniffing to figure out what kind of text
it is given. The sniffing is very simple - it just looks for <html> tag
in the first few characters of the text. I've seen this problem with
regular standalone IE, when a) a page has, say, a large comment at the
top before <html> tag, and b) the server sends an incorrect Content-Type
header, usually text/plain.

Yes, I figured that's what it was doing...just don't get why it only
occurs on the 2000 server machine.
That machine has I.E. 6.0.2800 and it appears there's no way of
upgrading to it 6.0.2900, which is what my XP machine has, where it
works fine.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top