public HttpResponseMessage Download(string indices = null) { XDocument doc = indices == null? HeavyProfiler.ExportXml() : HeavyProfiler.Find(indices).ExportXmlDocument(); using (MemoryStream ms = new MemoryStream()) { doc.Save(ms); string fileName = "Profile-{0}.xml".FormatWith(DateTime.Now.ToString("o").Replace(":", ".")); return(FilesController.GetHttpReponseMessage(new MemoryStream(ms.ToArray()), fileName)); } }
public FileResult DownloadFile(string indices) { XDocument doc = indices == null? HeavyProfiler.ExportXml() : HeavyProfiler.Find(indices).ExportXmlDocument(); using (MemoryStream ms = new MemoryStream()) { HeavyProfiler.ExportXml().Save(ms); string fileName = "Profile-{0}.xml".FormatWith(DateTime.Now.ToString("o").Replace(":", ".")); //Response.AddHeader("Content-Disposition", "attachment; filename=" + fileName); return(File(ms.ToArray(), "text/xml", fileName)); } }