• mvc actionresult返回各种文件


    public ActionResult ReviewFile(string folderName, string fileBasename, string extendName)
    {
    //以后根据后缀名返回相应的文件
    var fileFullName = "~/" + folderName + "/" + fileBasename + extendName;
    var path = Server.MapPath(fileFullName);
    switch (extendName)
    {
    case ".html":
    return File(path, "text/html");
    break;
    case ".txt":
    return File(path, "text/plain");
    break;
    case ".doc":
    return File(path, "application/msword");
    break;
    case ".xls":
    var downLoadFileName = fileBasename + ".xls";
    return File(path, "application/ms-excel", downLoadFileName);
    //return File(path, "application/x-excel");
    break;
    case ".pff":
    return File(path, "application/ms-powerpoint");
    break;
    case ".pdf":
    return File(path, "application/pdf");
    break;
    case ".zip":
    return File(path, "application/zip");
    break;
    default:
    var noPointExtentName = extendName.Substring(extendName.IndexOf('.') + 1);
    return File(path, "image/" + noPointExtentName);
    }
    }

  • 相关阅读:
    cocos3 单击
    cocos3 帧动画
    cocos3 动作和帧动画
    cocos3 场景切换特效
    cocos3 场景切换
    cocos3 error C2440
    c++ 匿名函数
    【leetcode】生成每种字符都是奇数个的字符串
    【leetcode】山羊拉丁文
    【leetcode】字符串的最大公因子
  • 原文地址:https://www.cnblogs.com/taoshengyujiu/p/5939291.html
Copyright © 2020-2023  润新知