• ashx


    private HttpResponse Response;
    private HttpRequest Request;
    public void ProcessRequest(HttpContext context)
    {
    context.Response.ContentType = "text/plain";
    Response = HttpContext.Current.Response;
    Request = HttpContext.Current.Request;
    string mothed= Request["mothed"];
    if (mothed == "1")
    {
    string str = "{'records':[{'Name':'Alfreds Futterkiste','City':'Berlin','Country':'Germany'},{'Name':'Ana Trujillo Emparedados y helados','City':'México D.F.','Country':'Mexico'}]}";
    JavaScriptSerializer jss = new JavaScriptSerializer();
    Response.Write(jss.Serialize(str));
    }

    //switch (mothed)
    //{
    // case "1":
    // Console.WriteLine("haha");
    // break;
    // default:
    // Console.WriteLine("NO");
    // break;
    //}

    //if (!string.IsNullOrEmpty(mothed))
    //{
    // System.Reflection.MethodInfo Method = this.GetType().GetMethod(mothed, System.Reflection.BindingFlags.NonPublic | System.Reflection.BindingFlags.Instance);//通过反射机制,直接对应到相应的方法
    // if (Method != null)
    // {
    // Method.Invoke(this, new object[] { context });
    // }
    //}
    //else
    //{
    // context.Response.Redirect("~/Login.aspx");
    //}
    }


    /// <summary>
    /// 将数据表序列化为json格式数据返回
    /// </summary>
    /// <param name="table"></param>
    /// <returns></returns>
    private string DataTableJSON(DataTable table)
    {
    List<Dictionary<string, object>> list = new List<Dictionary<string, object>>();
    foreach (DataRow row in table.Rows)
    {
    Dictionary<string, object> dict = new Dictionary<string, object>();
    foreach (DataColumn col in table.Columns)
    {
    dict[col.ColumnName] = row[col];
    }
    list.Add(dict);
    }
    JavaScriptSerializer jss = new JavaScriptSerializer();
    return jss.Serialize(list);
    }


    public bool IsReusable
    {
    get
    {
    return false;
    }
    }
    }
    }

  • 相关阅读:
    codeforces 733D
    HDU2647
    匈牙利算法 DFS模板(了解度+1)
    HDU1532 网络流:最大流之福德福克森算法
    mysql5 解压版 安装 建用户授权采坑
    Spring Boot 相关随笔
    Spring Boot 项目jar包 构建运行
    随笔小结
    war包 jar包理解(记录)
    vue axios异步请求及回调函数(前台)
  • 原文地址:https://www.cnblogs.com/liwp/p/6640946.html
Copyright © 2020-2023  润新知