• asp.net页面中文件下载的2种方式


    //Write pdf bytes to outputstream
            // 在线打开
            if (DKFS == "pdf")
            {
                Response.ContentType = "application/pdf";
            }
            // 下载
            if (DKFS == "octet-stream")
            {
                Response.AddHeader("Content-Disposition", string.Format("attachment;Filename={0}.pdf", Server.UrlEncode(string.Format("租赁意见书({0})", CZRXM))));
            }

    通常使用:Response.BinaryWrite(m.ToArray());//m是MemoryStream

    记得最后加上

       Response.OutputStream.Flush();
            Response.OutputStream.Close();
            Response.End();// 很多文章都没有这一句,但是非常重要,我不加就会在post出来的文件末尾加上当前页面代码...好杯具

  • 相关阅读:
    Windows10 搭建 ElasticSearch 集群服务
    python开发目录
    nohup命令使用
    shell脚本概述
    关于ELK
    keepalived+DR
    shell脚本中awk的用法
    shell脚本中sed的用法
    shell脚本中grep的用法
    shell检测入侵与邮件报警
  • 原文地址:https://www.cnblogs.com/keyrratuff/p/1633579.html
Copyright © 2020-2023  润新知