Exemplo n.º 1
0
        public ActionResult Register(UserInfo user)
        {
            HttpPostedFileBase file = Request.Files["image1"];

            if (ModelState.IsValid)
            {
                if (file != null)
                {
                    string filePath     = file.FileName;
                    string fileName     = filePath.Substring(filePath.LastIndexOf("\\") + 1);
                    string serverpath   = Server.MapPath(@"\images\users\") + fileName;
                    string relativepath = @"/images/users/" + fileName;
                    file.SaveAs(serverpath);
                    user.User_Img = relativepath;
                }
                user.User_Time = DateTime.Now;

                usermanager.InsertUser(user);
                Session["User_Name"] = user.User_Name;
                UserInfo users = usermanager.GetUserByName(user.User_Name);
                Session["UID"]      = users.UID.ToString();
                Session["User_Img"] = users.User_Img;
                return(Content("<script>alert('注册成功!');window.open('" + Url.Action("Index", "Index") + "','_self');</script>"));
            }
            ViewBag.usersex = new string[] { "男", " 女" };
            return(View(user));
        }
Exemplo n.º 2
0
        public string GetUserByName(string name)
        {
            UserInfoManager manager = new UserInfoManager();

            return(new JavaScriptSerializer().Serialize(manager.GetUserByName(name)));
        }