0
我想让用户保存一个xml文件到他选择的位置。你有任何如何写一个asp.net mvc 2应用程序的saveas位置的例子吗?在asp.net中打开saveas对话框mvc 2
我想让用户保存一个xml文件到他选择的位置。你有任何如何写一个asp.net mvc 2应用程序的saveas位置的例子吗?在asp.net中打开saveas对话框mvc 2
你可以使用Content-Disposition头,并指定attachment
属性,它会提示用户另存为对话框:
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");
}