简体   繁体   English

ASP.NET 4.0站点中的X-UA兼容元标记不起作用

[英]X-UA-Compatible meta tag in ASP.NET 4.0 site doesn't work

I am writting an asp.net 4 application and i want my application to work in compatiable mode (IE8 AND IE9) . 我正在编写一个asp.net 4应用程序,并且希望我的应用程序在兼容模式下工作(IE8和IE9)。

I have used following meta tag so far and it is not working. 到目前为止,我已经使用了以下meta标记,但无法正常工作。 (HAVE TRIED WITH "IE=8" AS WELL) (也尝试过“ IE = 8”)

I have followed this thread but no luck so far; 我遵循了这个主题,但到目前为止还没有运气。

Setting X-UA-Compatible meta tag in ASP.NET 4.0 site doesn't work 在ASP.NET 4.0站点中设置X-UA兼容的元标记不起作用

I don't know if it is a known bug? 我不知道这是不是已知的错误? http://connect.microsoft.com/VisualStudio/feedback/details/581278/setting-x-ua-compatible-meta-tag-in-asp-net-4-0-site-doesn-t-work-yes-it-s-at-the-top# http://connect.microsoft.com/VisualStudio/feedback/details/581278/setting-x-ua-compatible-meta-tag-in-asp-net-4-0-site-doesn-t-work-yes-它是最高的#

ADDED: 添加:

If i remove 'StyleSheetTheme' from the page tag then it renders in compatiable mode. 如果我从页面标记中删除“ StyleSheetTheme”,则它将以兼容模式呈现。

Any way to fix it? 有什么办法解决吗?

Possible solution: 可能的解决方案:

It works if i add meta tag dynamically on the page load event and leven the stylesheet value in the page tag. 如果我在页面加载事件中动态添加元标记,并在页面标记中保留样式表值,则该方法有效。

Dim metaTag As New HtmlMeta() 昏暗的metaTag作为新的HtmlMeta()

metaTag.Attributes.Add("http-equiv", "X-UA-Compatible") metaTag.Attributes.Add(“ http-equiv”,“ X-UA-Compatible”)

metaTag.Attributes.Add("content", "ID=EmulateIE7") metaTag.Attributes.Add(“ content”,“ ID = EmulateIE7”)

Page.Header.Controls.AddAt(0, metaTag) Page.Header.Controls.AddAt(0,metaTag)

Do you think its a right way of doing it? 您认为这样做正确吗? any other better solution? 还有其他更好的解决方案吗?

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

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