zoukankan      html  css  js  c++  java
  • C# 通过form表单下载文本文件

     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();
  • 相关阅读:
    BZOJ-3495 前缀优化建图2-SAT
    洛谷P3979 遥远的国度 树链剖分+分类讨论
    hdu
    hdu
    poj
    poj-1330(暴力写的lca)
    树链剖分
    Dijkstra
    Floyed
    最短路径
  • 原文地址:https://www.cnblogs.com/zhangwei595806165/p/4532740.html
Copyright © 2011-2022 走看看