浏览器如果有pdf插件就会直接在浏览器打开pdf文件,而不会出现下载对话框
半年后我也要成为这里的高手,等着瞧吧

解决方案 »

  1.   

    不好,这一问把偶问蒙了 ....1。
    下载代码片段在哪里啊?用的什么下载代码?二进制流下载?用 window.open 打开?关于空白页问题,我碰到过,但是尝试其他客户端,又没有这种现象,我也不知道具体原因也许是,由于你指定的文件格式,在客户端上没有对应可打开的应用程序
    2。
    假如你装了 pdf 阅读器,会自动打开的
      

  2.   

    起个脚本.在输出内容前.先发送 传送附件送.即可...
    response.setHeader("Content-Disposition", "attachment;filename=" + URLEncoder.encode(filename,"UTF8"));
      

  3.   

    下面这段下载代码片段,在我机器上,测试了多种文件类型,是不会出现你的问题:protected void Page_Init(object sender, EventArgs e)
        {
            string downFilePath = Server.MapPath("01.初识 ASP.NET.pps");
            System.IO.FileInfo downFileInfo = new System.IO.FileInfo(downFilePath);        if (!downFileInfo.Exists) throw new Exception("文件不存在。");
            const int CHUNK_SIZE = 10000; // 指定块大小
            byte[] buffer = new byte[CHUNK_SIZE];        Response.Clear();
            // fails to down the big file with both the following methods
            // error: System.ArgumentOutOfRangeException: 大小参数必须介于零和最大的 Int32 值之间。
            // Response.WriteFile(downFilePath);
            // OR
            // Response.TransmitFile(downFilePath); // ASP.NET 2.0 supported
            //
            using (System.IO.FileStream iStream = System.IO.File.OpenRead(downFilePath)) {
                long dataLengthToRead = iStream.Length;
                Response.ContentType = "application/octet-stream";
                Response.AddHeader("Content-Disposition",
                                   "attachment; filename=" + Server.UrlPathEncode(downFileInfo.Name)); // 对文件名进行编码
                while (dataLengthToRead > 0 && Response.IsClientConnected) {
                    int lengthRead = iStream.Read(buffer, 0, CHUNK_SIZE);
                    Response.OutputStream.Write(buffer, 0, lengthRead);
                    Response.Flush();
                    dataLengthToRead = dataLengthToRead - lengthRead;
                }
            }
            Response.Close();
        }