Force Browser and Document Mode in ASP.Net Application - asp.net

IE9+ sometimes have Browser Mode/Document Mode set to earlier versions or set to compatibility mode. This causes issues in my application whereby javascript doesn't run.
Is there a way to force these to be the latest standards or to a particular standard, or is there something in my document in the type or head that can define this?

Yes, totally possible. Just make sure you use the content="IE-Edge" in your Master/layout page. this ensures IE is running on its standard mode. If you want a specific mode, replace it with content="IE9" or content="IE8"
<meta http-equiv="X-UA-Compatible" content="IE=Edge">

Related

IE11 always render page in Document mode EDGE on locally hosted website

In IE11, my local hosted sites always renders with Document Mode= EDGE. Technically it should use doctype IE9, because of my page doctype
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
Below are steps i have preformed before posting
unchecked "Display internet sites in Compatibility View" from
IE, also my compatibility view list is empty.
Check my machine.config,web.config(global),web.config(website).
there is no Compatibility relevant configuration in them.
Also there is no metadata in my page the force browser to render it in
EDGE mode.
My dev environment is Windows7 64bit, ASP.net 4.5 and IIS 7.5
Thanks for reading the question.
Your DOCTYPE declaration will trigger the highest mode available to the version of IE used to view the page.
To force the page to IE9 standards mode, add the following as the first line of your page's section:
<meta http-equiv="x-ua-compatible" content="IE=9">
Please note that this may not be an ideal experience in the long run. When you view the page using MS Edge, it will be rendered in Edge mode (since Edge does not support x-ua-compatible). Also, the IE9 specific features you're hoping to rely on may have been removed in a more recent version of IE.
Hope this helps...
-- Lance

Issues when IE browser mode =11 and document mode=7

I have my application set to document mode=7 through webconfig. When this application is deployed in a windows server 2008 r2, and when i try to access it through internet, the document mode = 7 but my browser mode = 11. Most of the functionalities like sorting of ListView, selected change of checkbox is not working. When i change the browser mode to 7 using IE Explorer, it is functional. How can this be resolved?
You need to either set the X-UA-Compatible META tag like this:
<meta http-equiv="X-UA-Compatible" content="IE=7">
or add a custom header for X-UA-Compatible via IIS, the web.config or in C#:
HttpContext.Response.AddHeader("X-UA-Compatible", "IE-edge");
You can add the custom header in the web.config, see http://www.iis.net/configreference/system.webserver/httpprotocol/customheaders for help.
A word of advice, you need to take the time to upgrade the site to work with modern standards or you are going to lock yourself into a corner. IE 7 is almost a decade old, so consider that.

RadGrid + ASP.NET + IE10 Issue

I've added a RadGrid to an older ASPX and it works fine in Chrome and FireFox. Internet Explorer 10 does not render any of the sprites like the green plus sign for 'Insert new record' or even the funnels for the filter buttons. Clicking the empty space where the image ought to be works: the filter menu appears as does the insert form template appears.
Does anyone have any idea what could be the cause of this?
Some notes:
I have changed the meta tag to IE-9 compatibility with no success.
The console in IE shows an error when calling __defineGetter__. I haven't traced this too far; not sure if it's relevant to my problem.
The RadGrid operates fine, the only issue is that IE10 does not load
the image sprites. I've cleared my cache multiple times and have had
another user test it with the same result.
RadGrid should work out of the box with IE 10. Make sure you're running the latest version of the Telerik controls and clean out IE 10's cache. If that doesn't work I would check with Telerik's support directly...
Maybe the DocType, try:
<!DOCTYPE html>
Make sure compatibility mode is not being used:
<meta http-equiv="X-UA-Compatible" content="IE=edge" />

Local website renders differently using (IP address or machine name) vs localhost?

I have an MVC3 (razor) site published to IIS7 locally for testing purposes.
When I access the site via "localhost" it looks different from when I access using the IP address or machinename?
I have cleared my cache and re-loaded the pages to confirm and they still appear the different. The CSS must be loading to give the correct fonts/colours etc, although ":hover" elements appear to load much slower?
I am using JQuery/JQueryUI on the site if that helps identify the problem?
Any ideas?
Edit: More info
The titles, labels and table definition are build from ViewBag.Title, or looping through rows in a ViewModel - nothing clever, just standard MVC3/Razor stuff.
The same css file is used for every page, and F12 in IE8 shows the correct css has been loaded.
Title/subtitle font sizes/colours are correct, just their positioning is out?
Table border appears thicker?
Positioning generally seems a little "out", but I can't understand why there is this difference?
Can a firewall/AV package strip out positioning?
The same css file is used for every page, and F12 in IE8 shows the
correct css has been loaded.
Developer Tools should show that IE is not using the same "Browser Mode"/"Document Mode" between the two instances of the site, because that's the problem here. IE defaults to different modes depending on if you're using a machine name or not (amongst other things).
Adding this to your <head> should sort out the problem:
<meta http-equiv="X-UA-Compatible" content="IE=edge">
I had a similar issue, where the sizes differed from the local development site to the one on the production server. Turned out that I forgot the zoom level to 90% when viewing the development version... This answer helped me realize that: https://superuser.com/questions/315448/different-font-size-between-localhost-and-remote-server-in-firefox
I had exactly similar issue in IE11, I used this code
<meta http-equiv="X-UA-Compatible" content="IE=11">
And now whether its localhost or my machine name, the page always rendered nicely.
Just wanted to add, that if you use HTML5 tags (nav, header etc.) IE8 will render different on localhost and remote host.
If you add:
<!--[if lt IE 9]>
<script>
document.createElement('header');
document.createElement('nav');
</script>
<![endif]-->
Then the IE8 will show the same on local and remote host.

Classic ASP page automatically sets Quriks mode as default in IE 8

While viewing the HTML IE 8 sets the default document mode as IE8 Standards as it should but it enters quirks mode on an asp page.
Even if I use <!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
it doesn't really help.
What should I do?
First thing I would do would be place identical output in a HTM file and visit that instead. If you get different results then there really is something wierd going on because I doubt IE8 has any way to treat "asp" any differently.
BTW, How do you know its actually going into quirksmode?
What happens if you use stronger DTD like this:-
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01//EN" "http://www.w3.org/TR/html4/strict.dtd">
Does it still remain in quirksmode?
You're not confusing IE7 compatibility with Quirksmode are you?
IE7 had a number of bugs in how it render even Standards mode HTML, perhaps what are seeing is IE7 compatibility instead.
Use fiddler to examine the headers being sent with the content. Is there a header like this:-
X-UA-Compatible: IE=EmulateIE7
in the response?
Is the Compatibility button present next to address in the brower UI?
The only thing that actually works is <meta http-equiv="X-UA-Compatible" content="IE=8"/>, other browsers will ignore it but IE will be forced to be in IE-8 mode unless you've done something really stupid like putting something before the HTML.
I write standards based classic ASP all the time. The things to check would be your HTTP headers. Make sure something isn't being inserted into your HTTP header to cause it to use quirks mode. Might check your IIS box to make sure there isn't something being sent in the "Custom HTTP Headers" section in IIS. Also, check that your doctype is indeed correct. Lastly, make sure that you do not have any of IE's special meta tags that can change the rendering mode. Just because classic ASP is old doesn't mean that the browser would display it any different than any other HTML page. Honestly the browser doesn't really even care what the extension is. If it is served as html mime type then it will render as such.

Resources