Shtml 中的UTF8 BOM问题

最近使用到SSI技术,发现一个问题,即IE7,IE6在解析IIS生成的页面时,出现了错位,最后,把html粘贴到notepad++里面出现了一个问号,造成了页面的错位,经过大量的google,终于解决了,是由于BOM造成的,即不使用UTF-8编码,而是使用UTF-8 no bom进行编码,代码如下.

  using (XmlReader reader = System.Xml.XmlReader.Create(new System.IO.StringReader(xmlData)))

            {

                using (FileStream fs = new FileStream(_module.Target, FileMode.Create))

                {

                    Encoding utf8noBOM = new UTF8Encoding(false);   


                    using (TextWriter tw = new StreamWriter(fs, utf8noBOM))

                    {

                        xslt1.Transform(new XmlInput(reader), null, new XmlOutput(tw));

                        fs.Flush();

                    }

                 

                }

            } 

原文地址:https://www.cnblogs.com/cpsing/p/1603994.html