2012-05-09 154 views
0

我有一個需要由客戶端下載的XDocument對象。這個XML將在page_load上生成,然後作爲下載發送給用戶。將XML文件發送到客戶端

我不能找出如何發送對象到客戶端,而不需要一個acctual文件。 任何想法?

+1

見http://stackoverflow.com/questions/5806675/how-to-dynamically-creating-the-xml-file-content-and-sending-as-a-text-file-in(不相當重複但相關) –

+0

你在頁面上顯示的xml是什麼? –

+0

不會從數據源生成xml,然後將其作爲文件發送給用戶進行下載。 xml將不會顯示在頁面上。 –

回答

0

如上所述,我檢查this other post不完全相同,但足夠接近。

Response.Clear(); 
Response.ContentType = "text/xml"; 
Response.AppendHeader("Content-Disposition","attachment;filename=" + DateTime.Now+".xml"); 
Response.Write(doc.ToString()); 
Response.End(); 
相關問題