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

ASP.NET
dotNET下面调用Access中存储过程的方法
DataSet 的 Merge 方法研究
C#中using关键字的使用
Visual C#程序设计技巧小结
Creating GUIDs in c#
C#覆盖虚接口
在C#中应用哈希表(Hashtable)
对C#泛型中的new()约束的一点思考
身份证15To18 的算法(C#)
ADO.NET的结构体系。
ADO.NET的DataSet和ADO的Recordset的比较
OpenGLStepbyS
.NET对软件安装的冲击
IsVS.NETreadyforenterprise?(1)
IsVS.NETreadyforenterprise?(5)
IsVS.NETreadyforenterprise?(6)
.Net和Java有何相似之处
Hi,现在我们暂时不谈Passport
替代System.Web.Mail的新类库(新增邮件列表功能)
C#和VB.NET的区别

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


出处:互联网   整理: 软晨网(RuanChen.com)   发布: 2009-08-14   浏览: 129 ::
收藏到网摘: 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"-->

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