public ActionResult ShowLocalizedXML(int id)
{
string orderName = "";
string xmlString = GetXmlStream(id,out orderName);
ViewBag.Xml = xmlString; XmlDocument doc = new XmlDocument();
doc.CreateComment(xmlString); byte[] array = Encoding.UTF8.GetBytes(xmlString);
//array = UnicodeEncoding.Convert(Encoding.UTF8, Encoding.Unicode, array);
MemoryStream stream = new MemoryStream(array); Response.Cache.SetCacheability(HttpCacheability.NoCache);
Response.ContentType = "application/octet-stream";
Response.AppendHeader("Content-Disposition", "attachment; filename="+orderName+".xml");//Filename改成什么格式,就会下载什么格式文件
Response.AppendHeader("Content-Length", "" + stream.Length); byte[] bts = new byte[stream.Length];
stream.Seek(, SeekOrigin.Begin);
stream.Read(bts, , (int)stream.Length); Response.OutputStream.Write(bts, , bts.Length);
return View();
}