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

ASP.NET
asp.net GridView控件中模板列CheckBox全选、反选、取消
asp.net GridView 删除时弹出确认对话框(包括内容提示)
asp.net DropDownList 三级联动下拉菜单实现代码
asp DataTable添加列和行的三种方法
Asp.net 页面调用javascript变量的值
asp.net 长文章通过设定的行数分页
asp.net 定时间点执行任务的简易解决办法
asp.net 页面延时五秒,跳转到另外的页面
asp.net 动态输出透明gif图片
asp.net DataList与Repeater用法区别
asp.net Javascript获取CheckBoxList的value
asp.net程序在调式和发布之间图片路径问题的解决方法
asp.net下生成英文字符数字验证码的代码
asp.net 页面版文本框智能提示JSCode (升级版)
ASP.NET URL伪静态重写实现方法
ASP.NET 2.0 中Forms安全认证
asp.net 动态添加多个用户控件
asp.net Repeater显示父子表数据,无闪烁
asp.net 无法获取的内部内容,因为该内容不是文本 的解决方法
asp.net GridView排序简单实现

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


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

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