3

I have a website running on a server in IIS6. The website is configured with two hostheader bindings on port 80:

  • mywebsite1 <- requires an entry in local windows hosts file to fake a DNS entry
  • mywebsite2.mydomain.com <- uses DNS

So, in theory using a web browser to access either:

...should both show the exact same website in my browser.

However, when I use IE9 to view http://mywebsite1/, the UserAgent that the browser sends to the web server is this:

Mozilla/4.0+(compatible;+MSIE+7.0;+Windows+NT+6.1;+Trident/5.0;+SLCC2;+.NET+CLR+2.0.50727;+.NET+CLR+3.5.30729;+.NET+CLR+3.0.30729;+Media+Center+PC+6.0;+Tablet+PC+2.0;+MS-RTC+LM+8;+OfficeLiveConnector.1.5;+OfficeLivePatch.1.3;+.NET4.0C)

But when I use IE9 to view http://mywebsite2.mydomain.com/, the UserAgent that the browser sends to the web server is this:

Mozilla/5.0+(compatible;+MSIE+9.0;+Windows+NT+6.1;+Trident/5.0)

Why would IE9 send a different UserAgent string in these two situations? The browser is also emulating the rendering rules for these user agents, so this is causing nightmare CSS problems!

Additional info:

  • I have included in the page head tag.
  • The website is ASP.NET Framework 3.
  • The web server is IIS 6.
  • The web browser is IE9.
  • (let me know if you want me to clarify anything else)
BG100
  • 4,481
  • 2
  • 37
  • 64

2 Answers2

4

IE9 reports Mozilla/4.0 when in Compatibility View, did you click the "torn page" icon when viewing your http://mywebsite1/ ? (The view can also be requested by the html thats served.)

Alex K.
  • 171,639
  • 30
  • 264
  • 288
  • Ah yes, that makes both URLs consistent, but actually it's the other hostheader version that shows the "torn page" icon. http://mywebsite1/ does not show a "torn page" icon. What triggers the torn page to show in IE9? – BG100 Jun 06 '11 at 16:16
  • Response headers from the server or a meta tag in the HTML can do it, or if you mis-click and set the view, it sticks - take a look @ http://stackoverflow.com/questions/3726357/why-does-ie9-switch-to-compatibility-mode-on-my-website – Alex K. Jun 06 '11 at 16:19
0

This will change the useragent; however, when I change the useragent it will be for only the site i'm on and i surf the web the useragent will go back to it's default. This what I use for the code to change the useragent

WebBrowser1.Navigate(txtAddressBar.Text, Nothing, Nothing, "user-agent:" & "Mozilla/5.0 (Windows; U; Windows NT 5.1; en-US) AppleWebKit/532.2 (KHTML, like Gecko) ChromePlus/4.0.222.3 Chrome/4.0.222.3 Safari/532.2")

This code post to be one line; however, I don't know how to do that on here yet.

Scotty
  • 11
  • 2