public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; //context.Response.Write("Hello World"); var userName = context.Request["userName"]; var type = context.Request["con"]; User_Table getUser = new User_Table(); switch (type) { case "id": getUser = User.GetUserTableByConn(userName, "id"); break; case "name": getUser = User.GetUserTableByConn(userName, "name"); break; case "phone": getUser = User.GetUserTableByConn(userName, "phone"); break; } List <User_Table> getUserList = new List <User_Table>(); getUserList.Add(getUser); //创建可对数据进行Json【序列化/反序列化】操作对象 DataContractJsonSerializer dcjs = new DataContractJsonSerializer(typeof(List <User_Table>)); //将数据序列化为Jaon数据,通过流输出到客户端 dcjs.WriteObject(context.Response.OutputStream, getUserList); }
protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { User_Table u = new User_Table(); if (Session["loginUserName"] == null) { UserTable_BLL userData = new UserTable_BLL(); u = userData.GetUserTableByConn(Request.QueryString["userName"].ToString(), "name"); Session["loginUserName"] = u; } GetUserInfo(); } }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; User_Table user = userbll.GetUserTableByConn(context.Request["loginName"], "name"); user.U_Phone = context.Request["newPhone"]; int n = userbll.Update_UserTableData(user); if (n > 0) { context.Response.Write("1"); } else { context.Response.Write("0"); } }