当前位置: 首页 > 图文教程 > 网络编程 > ASP.NET > asp.net 里 include UTF8 垃圾问题

ASP.NET
细细品味ASP.NET(一)
细细品味ASP.NET(二)
细细品味ASP.NET(三)
细细品味ASP.NET(四)
细细品味ASP.NET(五)
用asp.net和xml做的新闻更新系统(1)
用asp.net和xml做的新闻更新系统(2)
用asp.net和xml做的新闻更新系统(3)
十天学会ASP.net(1)
十天学会ASP.net(2)
十天学会ASP.net(3)
十天学会ASP.net(4)
十天学会ASP.net(5)
十天学会ASP.net(6)
十天学会ASP.net(7)
十天学会ASP.net(8)
十天学会ASP.net(9)
十天学会ASP.net(10)
ASP.NET创建XML Web服务全接触(1)
ASP.NET创建XML Web服务全接触(2)

ASP.NET 中的 asp.net 里 include UTF8 垃圾问题


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 177 ::
收藏到网摘: n/a

    暂且不讨论为什么要用 SSI,而不用其它技术(如 UserControl)

  生成 index.shtml 肯定要带 BOM,其实带不带也不会影响页面上会出现空白行。

  index.shtml 内容如下:

         < html>
  < body>

  < !--#include file="head.shtml"-->

  < /body>

  < /html>
 
  1、head.shtml 保存为 UTF-8 带 BOM 时,会出现空白行(页面元素当然不止这些)。

  2、head.shtml 保存为 UTF-8 不带 BOM 时,会出现乱码,因为 SSInc.dll 加载这个文件时,不知道文件的编码(因为没有 BOM 签名),因此会按 GBK 来加载文件,最后乱码。。。

  所以,正也不行,反也不行,只有最后一招了,也是迫不得已。。

  改 index.shtml 为:

        < html>
  < body>

  < !--< !--#include file="head.shtml"-->

  < /body>

  < /html>
 
   在 head.shtml 的页开头加上

  < !--BOM-->

    内容

  意图 将 < !--#include 前的 < !-- 和 head.shtml 里的 BOM--> 用HTML注释掉,在 asp 下应该没有问题。

  2年前,用 asp.net include 就发现一个问题,就是它的解释方法和 asp 完全不同,不信可以试试

  < !--< !--#include file="head.shtml"-->执行结果等效于

  < !--#include file="head.shtml"-->

  又试了半个小时,几近绝望,被 IE 这个小小的问题折磨。一阵乱试后发现

  < !--#< !--#include file="head.shtml"-->

被忽略,暂时这样吧,期待更好的解决方案。。