简体   繁体   中英

ASP.NET Change IE document mode?

I've got a problem with an ASP.NET project. It uses .NET Framework 2 (old I know but can't update for other reasons) and when you open the site in Internet Explorer there are some bullet points which do not show. Set-up like:

<ul class="abc"><li>Bullet point 1</li></ul>

However when I open Internet Explorer developer tools by pressing F12 I can change the document mode from "Internet Explorer 7 Standards (Page Default)" to "Internet Explorer 8 Standards" the bullet points show correctly.

How can I change my solution so that all pages are set to use the Internet Explorer 8 standards by default?

Either simply just use <!DOCTYPE html> , or add this to your Web.config:

<system.webServer>
    <httpProtocol>
        <customHeaders>
            <add name="X-UA-Compatible" value="IE=Edge,chrome=1" />
        </customHeaders>
    </httpProtocol>
</system.webServer>

You can also use <meta http-equiv="X-UA-Compatible" content="IE=Edge,chrome=1" /> instead of a header, but it causes page redrawing.

Check the doctype. If I remember correctly the XHTML 1.0 strict doctype will enforce IE 7 mode. Also, you can use the X-UA compatible meta tag like so to put it in IE-9 mode: . Essentially, this isn't a function of ASP.Net at all. Your browser determines what engine to use first by your doctype then second by any over-riding features you've told it to use such as X-UA.

More information can be found at: https://msdn.microsoft.com/en-us/library/jj676915%28v=vs.85%29.aspx

The key point to remember with using X-UA is that it must be the very first tag in your . If you put it second it won't work.

Adding this under the DOCTYPE worked.

<meta http-equiv="x-ua-compatible" content="IE=Edge" >

It did not work when that was between the head tags. You can changed edge to 7/8/9 etc to suit.

Haven't tried but you need to have DOCTYPE such as <!DOCTYPE html>

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM