为什么websecurity.resetpassword总是返回false?

时间:2016-06-22 21:54:53

标签: asp.net-mvc

public ActionResult ResetPassword(ResetPassword model)
    {
        try
        {
            if (ModelState.IsValid)
            {
                //var errors = ModelState.Values.SelectMany(v => v.Errors);

                if (!WebSecurity.Initialized)
                {
                    WebSecurity.InitializeDatabaseConnection("DefaultConnection", "Members", "ID", "Name", autoCreateTables: true);
                }
                try
                {
                    string token = Request["code"];
                    string newpassword = Request["newpassword"];
                    string confirmpassword = Request["confirmpassword"];
                    string msg = "";
                    if (string.IsNullOrEmpty(token))
                    { Response.Redirect("~"); }
                    newpassword = Request["newpassword"];
                    confirmpassword = Request["confirmpassword"];
                    token = Request["code"];
                    try
                    {
                        if (WebSecurity.ResetPassword(token,newpassword))
                        {
                            Dictionary<string, string> j = new Dictionary<string, string>();
                            j.Add("MessageCode", "1");
                            return Json(j, JsonRequestBehavior.AllowGet);
                            }
                        else
                        {
                            Dictionary<string, string> jData = new Dictionary<string, string>();
                            jData.Add("MessageCode", "0");
                            return Json(jData, JsonRequestBehavior.AllowGet);
                        }
                    }
                    catch (Exception ex) { TempData["Error"] = "An error occured,please try again"; }
                }
                catch (Exception e)
                {
                    TempData["Error"] = "An error occured,please try again";
                }

                return View();
            }
            return View(model);
        }
        catch (Exception ex)
        {
            TempData["Error"] = "An error occured,please try again";
        }
        return View();
    }

我是conitnuosly gettin websecurity请求[&#34;代码&#34;] null请帮助

0 个答案:

没有答案