public void DownLoadConfigFile(string name)
        {
            //获取文件字符串内容
            var data = _service.ReadFileStr(_configureFilePath + name);
            MemoryStream ms = new MemoryStream(Encoding.Default.GetBytes(data));
            string filename = HttpUtility.UrlEncode(name);
            HttpContext.Current.Response.Clear();
            HttpContext.Current.Response.AddHeader("Content-Disposition", ("attachment;filename=" + filename));
            HttpContext.Current.Response.Charset = "UTF-8";
            HttpContext.Current.Response.ContentType = "text/json";
            HttpContext.Current.Response.BinaryWrite(ms.ToArray());
            HttpContext.Current.Response.Flush();
        }

参考:

ajax:

$("#myform").attr("action", "/AjaxSwitchConfigInfo/DownLoadConfigFile.cspx?name=" + $("#filename").val());
$("#myform").submit();

 

相关文章:

  • 2022-12-23
  • 2021-11-20
  • 2021-12-09
  • 2021-12-30
  • 2021-08-17
  • 2022-01-01
  • 2021-07-01
猜你喜欢
  • 2022-03-04
  • 2022-12-23
  • 2022-02-08
  • 2021-11-27
  • 2022-12-23
  • 2021-11-27
  • 2022-12-23
相关资源
相似解决方案