下载模板

控制器
#region 下载模板
public ActionResult Download()// 下载模板
{
string Path = Server.MapPath("~/Content/download/导入模板.xls");

if (System.IO.File.Exists(Path))
{
    // 设置Mime = MimeMapping映射文档扩展使Mime类型内容(注:需要.net4.5框架)
    string Mime = MimeMapping.GetMimeMapping(Path);

    // 返回映射为指定的文件名的Mime
    return File(new FileStream(Path, FileMode.Open), Mime, "导入模板.xls");// 下载模板
}
else
{
    return Content("下载文件不存在!");// 下载模板
}

}
#endregion

源代码

下载模板

JavaScript

猜你喜欢

转载自blog.csdn.net/weixin_44887862/article/details/89372850