<a href="<%#Eval("path") %>" target="_blank">下载</a>  点击下载后是浏览器直接打开文件,怎么弄成下载文件

解决方案 »

  1.   

    客户端决定的,设置content-type看看。没有办法。让客户配置本地的mime类型。
      

  2.   

    rar压缩包文件连接后就是提示下载。
      

  3.   

    那应该和下载文件类型有关系了
    css这类的就直接打开了,但是一般的都是保存的
      

  4.   

                string filePath = "";
                FileInfo Fi = new FileInfo(filePath);
                if (Fi.Exists)
                {
                    FileStream fs = new FileStream(filePath, FileMode.Open);
                    byte[] bytes = new byte[(int)fs.Length];
                    fs.Read(bytes, 0, bytes.Length);
                    fs.Close();
                    Response.ContentType = "application/octet-stream";//通知浏览器下载文件而不是打开
                    Response.AddHeader("Content-Disposition", "attachment; filename=" + HttpUtility.UrlEncode(dt.Rows[0]["Name"].ToString(), System.Text.Encoding.UTF8));
                    Response.BinaryWrite(bytes);
                    Response.Flush();
                    Response.End();
                }
      

  5.   

    <a href="download.aspx?id=<%#Eval("path") %>" target="_blank">
    Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(FileName), System.Text.Encoding.GetEncoding("utf-8")));
    Response.ContentType = "application/octet-stream";
    Response.WriteFile(Filepath);
    Response.End();
      

  6.   

    运行到 FileStream fs = new FileStream(filePath, FileMode.Open)时提示拒绝访问,没有权限