开发者

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");
}
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜