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;
    }
    }
    }
    }

  • 相关阅读:
    Silverlight之各种线程的操作
    MVVM之Event and Command
    Silverlight之DescriptionViewer
    MVVM之Validation
    蚁群算法(C语言实现)
    最小生成树的prim算法
    关于HashMap、LinkedHashMap与TreeMap
    Slope One :简单高效的协同过滤算法(Collaborative Filtering)——转
    java中使用匿名类重写
    Session学习:防止用户重复提交表单(单态设计模式原子设计模式+MD5技术&Base64算法)
  • 原文地址:https://www.cnblogs.com/liwp/p/6640946.html
Copyright © 2011-2022 走看看