zoukankan      html  css  js  c++  java
  • IE8的“文件下载的自动提示”

    IE8安全设置中“文件下载的自动提示”,IE9又没有了

    在IE8中这个默认是禁用的,这就导致如果用window.open打开文件,会发生一闪就没有结果了。把这个启用就可以了。

    当然 可以用代码加载文件,就不会出现这个问题了。

            string sFileName = Server.MapPath("~/Manage/Subject/Template.xls");
            FileStream fileStream = new FileStream(sFileName, FileMode.Open);
            long fileSize = fileStream.Length;
            byte[] fileBuffer = new byte[fileSize];
            fileStream.Read(fileBuffer, 0, (int)fileSize);
            //如果不写fileStream.Close()语句,用户在下载过程中选择取消,将不能再次下载
            fileStream.Close();
            Context.Response.ContentType = "application/octet-stream";
            Context.Response.AppendHeader("Content-Disposition", "attachment;filename=" + HttpUtility.UrlEncode("Template.xls", Encoding.UTF8));
            Context.Response.AddHeader("Content-Length", fileSize.ToString());

            Context.Response.BinaryWrite(fileBuffer);
            Context.Response.End();
            Context.Response.Close();

  • 相关阅读:
    日志收集
    解决spawn-fcgi child exited with: 1
    confluence启动关闭
    Informatica 启动、停止工作流命令
    启动obiee
    oracle修改连接空闲自动断开
    ORA-00845: MEMORY_TARGET not supported on this system
    svn执行clean up命令时报错
    手游推广
    phonegap/cordova 升级版本
  • 原文地址:https://www.cnblogs.com/cuihongyu3503319/p/2144384.html
Copyright © 2011-2022 走看看