首页 > 其他 > 详细

ashx

时间:2017-03-29 17:56:51      阅读:215      评论:0      收藏:0      [点我收藏+]

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

ashx

原文:http://www.cnblogs.com/liwp/p/6640946.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!