コード例 #1
0
        public void ProcessRequest(HttpContext context)
        {
            try
            {
                context.Response.ContentType = "text/plain";

                if (context.Session["User"] != null)
                {
                    User objUser = new User();
                    objUser = context.Session["User"] as User;
                    string strUserName = objUser.UserName;
                    context.Response.Write("當前用戶:" + strUserName);
                }
                else
                {
                    //context.Response.Redirect("../login.html");
                    context.Response.Write("logout");
                }
            }
            catch (Exception e)
            {

                context.Response.Write("error");
            }
        }
コード例 #2
0
        public void ProcessRequest(HttpContext context)
        {
            context.Response.ContentType = "text/plain";
            //context.Response.Write("Hello World");

            if (!string.IsNullOrEmpty(context.Request.QueryString["rdItem"]))
            {
                GenerateCheckCode(context);
            }
            else
            {
                string strUseID = context.Request["username"].ToString();
                string strPwd = context.Request["pwd"].ToString();
                string strCode = context.Request["Code"].ToString();

                if (context.Session["Code"] == null)
                {
                    context.Response.Write("overtime");
                }

                else if (strCode != context.Session["Code"].ToString())
                {
                    context.Response.Write("CodeError");
                }

                else
                {
                    DataTable dtb = CheckUser(strUseID, strPwd);
                    if (dtb.Rows.Count < 1)
                    {
                        context.Response.Write("ErrUser");
                    }
                    else
                    {
                        User user = new User();
                        user.Id = dtb.Rows[0].ItemArray[0].ToString().Trim();
                        user.UserCode = dtb.Rows[0].ItemArray[1].ToString().Trim();
                        user.UserName = dtb.Rows[0].ItemArray[2].ToString().Trim();
                        user.Password = dtb.Rows[0].ItemArray[3].ToString().Trim();
                        user.ImgPath = dtb.Rows[0].ItemArray[4].ToString().Trim();
                        user.UserTEL = dtb.Rows[0].ItemArray[5].ToString().Trim();
                        user.UserEmail = dtb.Rows[0].ItemArray[6].ToString().Trim();
                        user.UserMobile = dtb.Rows[0].ItemArray[7].ToString().Trim();
                        user.RoleCode = dtb.Rows[0].ItemArray[8].ToString().Trim();
                        user.UserIP = dtb.Rows[0].ItemArray[9].ToString().Trim();

                        context.Session["User"] = user;
                        context.Response.Write("success");
                    }
                }
            }
        }