【发布时间】:2012-09-01 05:33:45
【问题描述】:
我正在编写一个 asp.net 4 应用程序,我希望我的应用程序在兼容模式下工作(IE8 和 IE9)。
到目前为止,我已经使用了以下元标记,但它不起作用。 (也尝试过使用“IE=8”)
我已经关注了这个帖子,但到目前为止还没有运气;
Setting X-UA-Compatible meta tag in ASP.NET 4.0 site doesn't work
我不知道这是否是一个已知的错误? 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#
添加:
如果我从页面标签中删除“StyleSheetTheme”,那么它会以兼容模式呈现。
有什么办法解决吗?
可能的解决方案:
如果我在页面加载事件上动态添加元标记并在页面标记中添加样式表值,它会起作用。
将 metaTag 调暗为新的 HtmlMeta()
metaTag.Attributes.Add("http-equiv", "X-UA-Compatible")
metaTag.Attributes.Add("content", "ID=EmulateIE7")
Page.Header.Controls.AddAt(0, metaTag)
您认为这是正确的做法吗?还有其他更好的解决方案吗?
【问题讨论】:
标签: c# asp.net iis web-applications