专业网站建设品牌,十四年专业建站经验,服务6000+客户--广州京杭网络
免费热线:400-683-0016      微信咨询  |  联系我们

强制浏览器使用兼容模式,Web.config,httpProtocol

当前位置:网站建设 > 技术支持
资料来源:网络整理       时间:2023/2/14 0:40:06       共计:3635 浏览

对于一些政府类的网站,很多支持IE6~8,而不支持使用更高版本浏览器浏览。虽然有些浏览器会自动使用兼容模式,或有些人会手动调整浏览器的兼容模式,但不是每一个人、每一款浏览器都可以做到用兼容模式。所以,强制浏览器使用指定版本的兼容模式运行,变得势在必行。

1 2 3 4 5 6 7 8 9 10 11 12 13 14 <configuration>   <system.webServer>       <!-- 设定网站服务器以指定预设兼容性模式 Lionden -->     <httpProtocol>       <customHeaders>         <clear />         <add name="X-UA-Compatible" value="IE=EmulateIE7" />       </customHeaders>     </httpProtocol>     </system.webServer>   </configuration>


微软IIS知识链接:http://www.iis.net/configreference/system.webserver/httpprotocol;

using System;
using System.Text;
using Microsoft.Web.Administration;

internal static class Sample
{
   private static void Main()
   {
      using (ServerManager serverManager = new ServerManager())
      {
         Configuration config = serverManager.GetWebConfiguration("Default Web Site");

         ConfigurationSection httpProtocolSection = config.GetSection("system.webServer/httpProtocol");
         httpProtocolSection["allowKeepAlive"] = true;

         serverManager.CommitChanges();
      }
   }
}


版权说明:
本网站凡注明“广州京杭 原创”的皆为本站原创文章,如需转载请注明出处!
本网转载皆注明出处,遵循行业规范,如发现作品内容版权或其它问题的,请与我们联系处理!
欢迎扫描右侧微信二维码与我们联系。
·上一条:通过HTTP_USER_AGENT 分析访问者的操作系统环境 | ·下一条:禁止网站被别人通过iframe引用

Copyright © 广州京杭网络科技有限公司 2005-2025 版权所有    粤ICP备16019765号 

广州京杭网络科技有限公司 版权所有