views:

570

answers:

2

I am completely confused - I have a website that renders perfectly in IE8 when run through Cassini (in Visual Studio) but has several messed up elements (style/look) when deployed to localhost and viewed through the same browser (IE8).

I have run Beyond Compare 3 on the html and CSS files and they are exactly the same. Are there any circumstances where IIS7 could be somehow sending extra/different information to the browser? Has anyone run across something like this before?

Note that Chrome and Firefox both render the same webpage just fine through Cassini and IIS7.

(Update) What Browser Mode and Document Mode does IE8 Developer Tools think you are in if you press F12?

When running from Cassini (http://localhost:22120), IE8 stays in IE8 mode (with the option for turning on IE7 compatibility view) and everything looks great.

When running from IIS7 (http://{machine name}), IE8 automatically goes into in IE8 Compat View, IE7 standards and things look horrible.

A: 

If the page content is the same then compare the headers that the servers are sending with the page.

After kicking this around a bit I though about compatibility mode. Try manually forcing IE8 to render the page in compatibility mod. If the render doesn't change then you know that the issue is because IE is rendering that page in compatibility mode when reading it from that web server.

If the latter is the case look into http://msdn.microsoft.com/en-us/library/dd567845%28VS.85%29.aspx

JustSmith
This pretty much nails it, because *something* has to be different. It's got to be the content or the header.
Beska
+3  A: 

My assumption (as mentioned in my comment earlier) was that IE is working in a different rendering mode, depending on whether you are using IIS or Cassini, and this is causing the layout differences. It actually appears to be IE that is causing this, based on the settings found in Tools | Compatibility View Settings. There are two check boxes:

Display intranet sites in Compatibility View - this is checked by default. Display all websites in Compatibility View - this is not.

Either way, you should use the standard meta tag to force the mode you wish to be rendered in.

<meta http-equiv="X-UA-Compatible" content="IE=8" />

Hope this helps.

Paul Hammond
This is the answer. "http://localhost" is special-cased to be treated like Internet-zone content, while (by default) http://machinename is treated like Intranet-zone content.
EricLaw -MSFT-
A little bit of extra info which I found was required to fix my problem: when run in intranet mode, if not specified otherwise, IE defaults to "IE=EumulateIE7" mode. Whereas the default for the internet zone is "IE=8" mode. Since my site was working fine on the intranet, I had to use "IE=7". (IE=EmulateIE7 would have also worked, but under some circumstances this can wind up rendering in IE5 mode, which is not exactly desirable)
humble coffee