13

I have googled around for the answer to this question, but haven't come up with anything. Maybe the search terms I used were too generic... Anyway, here goes:

I am discovering the joys of web design and ASP.NET, and the nightmare of trying to get things to display in the same way in IE and all the other browsers. I am working in VS2010 and debugging my website using IE8. What I really don't get is why the website once I publish it looks different in IE from the way it looks in debug mode... I mean small things only, like border in gridviews disappearing in the published site, simple html horizontal rules aren't the same either.

It also messed up my list menu pretty bad, but I managed to fix that with the *display: inline; hack. The weird thing is that it doesn't need it in debug mode, but needs it for the published website.

I am hosting the site on my own machine, running Win XP Pro and hosting through IIS with .NET 4.0... Could the issue be IIS related?

Any help would be much appreciated, because those differences are just ridiculous and are driving me to desperation. I wish everyone over here would use Chrome or Safari, but unfortunately IE still rules in Japan...

4
  • are you looking at the site from the exact same browser? no compatibility mode etc?
    – JohnIdol
    Commented Mar 2, 2011 at 9:12
  • Can you provide screen shot of the two and preferably highlighting the differences? No, IIS won't make this happen. This is not an IE problem per-se.
    – Shiv Kumar
    Commented Mar 2, 2011 at 9:15
  • @JohnIdol - Yes, the same browser on the same machine. The appearance of the website does not change with Chrome, Safari or Opera, but it is different with IE...
    – David
    Commented Mar 3, 2011 at 15:03
  • @Shiv Kumar - I'll try to put up screenshots if i can figure out how. I think you are right though in that it is not IIS, since in that case all browsers should be affected.
    – David
    Commented Mar 3, 2011 at 15:04

5 Answers 5

11

This works for me, overrides the setting in ie

META Tag in HEAD element of your web page (or better in master page)

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

link here to info http://blogs.msdn.com/b/askie/archive/2009/03/23/understanding-compatibility-modes-in-internet-explorer-8.aspx

2
  • Yup, that's how I ended up working around it. Crazy that you have to resort to that kind of stuff though...
    – yu_ominae
    Commented Sep 15, 2011 at 19:18
  • 1
    THIS SAVED MY DAY (Sorry had to use caps because I was going crazy!!!) Anyone knows why this happens? Commented Sep 16, 2014 at 20:44
7

I find it better to override compatibility in the HTTP Reponse Headers in IIS, adding header:

X-UA-Compatible: IE=Edge

The IE=Edge part will set compatibility to use the highest mode available, will apply to all users, and also apply to all pages in the site whilst only having to put the header in one place.

2
  • This is the route I went. The website I am working with uses framesets instead of a master page, so adding this to every ASPX header would just be impractical. Adding it to my website in IIS was the ticket. Commented Oct 1, 2013 at 12:24
  • Just to "piggyback" off Andrew here, if anyone is having trouble with this in IIS, the same can be done in your web.config file. Place the following <add name="X-UA-Compatible" value="IE=edge,chrome=1" /> under your <system.webServer><httpProtocol><customHeaders> tags and IIS will pick up this and add it to it's settings.
    – haag1
    Commented Jan 10, 2019 at 14:07
6

I've seen similar behavior related to trusted sites/intranet sites/internet sites security settings. When you run in debug mode is the URL you are using different from when you publish it? I've seen sometimes when I debug using a URL like http://localhost/xxx and when I access the same site straight from IIS using a URL like http://machinename.domain.com/xxx that one resolves to a trusted site or local intranet and the other to internet and it changes the appearance based on the IE settings.

5
  • I guess that could be it. When I debug it does run via the localhost/website address, whilst when I deploy it access goes via the machine/website address like you said. I'll check it out tomorrow, see if I can twiddle the settings to get it to go away.
    – David
    Commented Mar 3, 2011 at 15:10
  • That is it. IE defaults to a trusted site when the domain name does not include ".". Just tested it by accessing the site via ComputerName/SiteName and ComputerIP/SiteName. The site displays as it should when accessed by specifying the IP. What a pain. Thanks much for you help!
    – David
    Commented Mar 3, 2011 at 23:42
  • Glad I could help. This one still causes me problems on a near weekly basis. Looks perfect, then it goes to test and it comes back because it doesn't look right. Drives me crazy. Commented Mar 4, 2011 at 1:41
  • Wow, this helped me too thanks! Does that mean that we should always boot up from VS2010 via the ip address and not the localhost?
    – Diskdrive
    Commented Apr 13, 2011 at 1:39
  • 1
    I've done a bit more research on this it is the "Display intranet sites in Compatibility View" setting in the Tools->Compatibility View Settings menu of IE8 and IE9. If your web application is going to be deployed on an intranet this might be a problem because this is on by default. If not, turn it off on your dev machine and it will appear normally. Commented May 5, 2011 at 6:56
1

For those using ASP.NET MVC, you can add kgp4death's

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

to the head element in your _Layout.cshtml.

0

I think you did not have given the correct path in the <script src="path">. Please check your path and also check the related file u must place this file in the project folder

I hope this suggestion solve your problem

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.