在网上看到关于ajax和iframe下载文件的例子,但基本上都是一样的,看起来很不理解,希望能有更具体的例子供欣赏一下

解决方案 »

  1.   

    是不是这个:http://hi.baidu.com/freezesoul/blog/item/6a4c4f08d65bb6900a7b82d5.html
      

  2.   

    string filePath="";
    ScriptManager.RegisterStartupScript(this, this.GetType(), "RegisterStartupScript"
    , String.Format("window.navigate('DownloadFile.aspx?Filename={0}');", Server.UrlEncode(filePath)), true); 
    DownloadFile.aspx
    string  Filename= Server.MapPath("../path/") +Request.QueryString["Filename"].ToString() ;
    Response.AppendHeader("Content-Disposition", "attachment;filename=" + System.Web.HttpUtility.UrlEncode(FileName.Substring(FileName.LastIndexOf('/') + 1), System.Text.Encoding.GetEncoding("utf-8")));
    Response.ContentType = "application/octet-stream";
    Response.WriteFile("" + dir.Trim() + FileName+"");
    Response.End();