zoukankan      html  css  js  c++  java
  • 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;
    }
    }
    }
    }

  • 相关阅读:
    豆瓣电台WP7客户端 MVVM重构记录之使用MVVM Light实现Event绑定
    使用DotNetOpenAuth来实现有道云笔记的授权
    豆瓣电台WP7客户端 MVVM重构记录之总结
    使用Npgsql连接Postgres
    WPF自定义一个MessageBox
    字符集其实很简单
    pytest封神之路第六步 断言技巧
    pytest封神之路第七步 用例查找原理
    一文搞懂Cookie,Session,Token,JWT
    典藏版Web功能测试用例库
  • 原文地址:https://www.cnblogs.com/liwp/p/6640946.html
Copyright © 2011-2022 走看看