链接:<a href="pdf/2011冶金展邀请函.pdf" target="_blank">点击下载</a>
按上面的链接没有装PDF软件的人点了会显示那个下载,有PDF的就直接打开了,有没有办法点击下载后无论有没有PDF软件都到有打开与另存为的那个选择呢?

解决方案 »

  1.   

    Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name)); //解决中文文件名乱码    
                Response.AddHeader("Content-length", file.Length.ToString());
                Response.ContentType = "application/pdf";
                Response.WriteFile(file.FullName);
                Response.End();
      

  2.   

            System.Web.HttpContext.Current.Response.Charset = "UTF-8";
            System.Web.HttpContext.Current.Response.ContentEncoding = System.Text.Encoding.UTF8;
            System.Web.HttpContext.Current.Response.ContentType = "application/ms-excel";
            System.Web.HttpContext.Current.Response.AppendHeader("Content-Disposition", "attachment;filename=aaaaaa.xls");
            System.Web.HttpContext.Current.Response.WriteFile(@"d:\aaaaaa.xls");
            System.Web.HttpContext.Current.Response.Flush();
            System.Web.HttpContext.Current.Response.End();
      

  3.   

    传值id到一个页面,在该页面写路径下载,就可以了少了一句:FileInfo file = new FileInfo(Server.MapPath("..//reports//erp.zip"));//路径Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name)); //解决中文文件名乱码    
                Response.AddHeader("Content-length", file.Length.ToString());
                Response.ContentType = "application/pdf";
                Response.WriteFile(file.FullName);
                Response.End();
      

  4.   

    FileInfo file = new FileInfo(Server.MapPath("..//reports//erp.zip"));//路径Response.ContentEncoding = System.Text.Encoding.GetEncoding("UTF-8"); //解决中文乱码
                Response.AddHeader("Content-Disposition", "attachment; filename=" + Server.UrlEncode(file.Name)); //解决中文文件名乱码    
                Response.AddHeader("Content-length", file.Length.ToString());
                Response.ContentType = "application/pdf";
                Response.WriteFile(file.FullName);
                Response.End();
      

  5.   

    有没有能用JS实现或直接HTML能实现的方法?
      

  6.   

    不用pdf直接挂在连接上,而是用压缩包zip的方式应该就可以了
      

  7.   

    下载文件string fileName = "";
                string filePath = Server.MapPath("");
                FileInfo fileInfo = new FileInfo(filePath);
                Response.Clear();
                Response.ClearContent();
                Response.ClearHeaders();
                Response.AddHeader("Content-Disposition", "attachment;filename=" + fileName);
                Response.AddHeader("Content-Length", fileInfo.Length.ToString());
                Response.AddHeader("Content-Transfer-Encoding", "binary");
                Response.ContentType = "application/octet-stream";
                Response.ContentEncoding = System.Text.Encoding.GetEncoding("gb2312");
                Response.WriteFile(fileInfo.FullName);
                Response.Flush();
                Response.End();