网站文件下载代码

效果图:

页面视图代码:

  <div style="float: right; padding-right: 5px;">
                Excel模板:@Html.ActionLink("下载模版.xls", "GetFile") 
  </div>

控制器代码:

        //下载模板
        public FileResult GetFile()
        {
            string path = "~/Content/Template/";
            string fileName = "学生导入模板.xls";
            return File(path + fileName, "text/plain", fileName);
        }
原文地址:https://www.cnblogs.com/yechangzhong-826217795/p/5623925.html