说明:只有在xp ie 6环境下有这种问题,ie6以上版本都没问题。
代码:
using (MemoryStream ms = new MemoryStream())
{
XmlWriterSettings settings = new XmlWriterSettings();
settings.Indent = true;
settings.Encoding = new UTF8Encoding(true);
//设置换行符
settings.NewLineChars = Environment.NewLine;
using (XmlWriter xmlWriter = XmlWriter.Create(ms, settings))
{
xmlWriter.WriteStartDocument(false);
xmlWriter.WriteStartElement("contact");
xmlWriter.WriteElementString("contactID", contactID);
xmlWriter.WriteElementString("name_en", name_en);
xmlWriter.WriteElementString("name_ch", name_ch);
xmlWriter.WriteElementString("PCDSNO", PCDSNO);
xmlWriter.WriteElementString("contactQRCodeImg", contactQRCodeImg);
xmlWriter.WriteEndElement();
xmlWriter.WriteEndDocument();
}
string xml = Encoding.UTF8.GetString(ms.ToArray());
Response.Clear();
Response.ClearHeaders();
Response.Buffer = false;
Response.ContentType = "text/xml; characterset=utf-8";
Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode(ContactNO + @".xml"));
Response.AppendHeader("Content-Length", ms.Length.ToString());
Response.Write(xml);
Response.Flush();
Response.End();
}
加一句
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
用ie6的不多了
有时候还是需要考虑到ie6的,因为还有很多人用xp的,你可以考虑用你们都用户,升级为ie8吧,现在没有ie6,做这个测试了
还不放弃IE6 啊