孟老大
在客户端浏览各类文档,使用超链接方式,文件流方式都会有下载提示,我希望在IE中直接打开,没有下载提示如何实现?谢谢!下面是我目前使用的代码string path = Server.MapPath(fileInfo_Path);
                FileStream fileStream = new FileStream(path, FileMode.Open, FileAccess.Read);
                byte[] MyData = new byte[fileStream.Length];
                fileStream.Read(MyData, 0, System.Convert.ToInt32(fileStream.Length));
                fileStream.Close();                   this.Response.Clear();
                this.Response.ClearHeaders();
                this.Response.Buffer = true;
                this.Response.ContentType = contentType;
                this.Response.Expires = -1;
                this.Response.AppendHeader("Content-Language", "zh");
                this.Response.AppendHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode(file_name, System.Text.Encoding.UTF8));
                Response.ContentEncoding = System.Text.Encoding.Default;
                this.Response.BinaryWrite(MyData);
                this.Response.Flush();
                this.Response.End();

解决方案 »

  1.   


    string path = Server.MapPath(fileInfo_Path);
                    FileInfo DownloadFile = new FileInfo(path);
                    this.Response.Clear();
                    this.Response.ClearHeaders();
                    this.Response.Buffer = true;
                    this.Response.ContentType = contentType;
                    this.Response.Expires = -1;
                    this.Response.AppendHeader("Content-Language", "zh");
                    this.Response.AppendHeader("Content-Disposition", "inline;filename=" + HttpUtility.UrlEncode(file_name, System.Text.Encoding.UTF8));
                    Response.ContentEncoding = System.Text.Encoding.Default;
                    this.Response.AppendHeader("Content-Length", DownloadFile.Length.ToString());
                    this.Response.WriteFile(DownloadFile.FullName);
                    this.Response.Flush();
                    this.Response.End();我这样写也是有下载提示
      

  2.   

    这个IE总会弹出那个下载提示的,除非自己修改IE的DownloadManager,替代自己的,然后捕捉这个弹出对话框操作,然后直接使用对话框中的Open方式...