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 b开发者_如何学Pythonrowser to access either:
- http://mywebsite1/
- http://mywebsite2.mydomain.com/
...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)
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.)
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.
精彩评论