首页 > 代码库 > 简单下载内容

简单下载内容

public void DownLoad(string wordcode, string wordname, string wordcopyright)
        {
            string outfn = "attachment;filename={0}.txt";
            Response.ContentType = "application/txt;charset=GB2312";
            Response.AddHeader("Content-Disposition", string.Format(outfn, wordcode));
            Response.Write(string.Format("{0}\r\n{1}", Server.UrlDecode(wordname), Server.UrlDecode(wordcopyright)));
        }


mvc中,view里将链接指向该action即可。

也可以通过js window.open 这个url。