open saveas dialog in asp.net mvc 2
i am trying to let a user save an xml file to a location of his choice. Do you have any examples 开发者_运维问答of how to write a saveas location for an asp.net mvc 2 app?
You could use the Content-Disposition header and specify the attachment
property which will prompt the user with a Save As dialog box:
public ActionResult Download()
{
var cd = new ContentDisposition
{
FileName = "foo.xml",
Inline = false
};
Response.AppendHeader("Content-Disposition", cd.ToString());
var xml = Encoding.Default.GetBytes("<root>some content</root>");
return File(xml, "text/xml");
}
精彩评论