部署后MVC身份验证失败

时间:2016-01-12 19:18:52

标签: c# asp.net-mvc visual-studio validation asp.net-mvc-4

我有一个MVC应用程序,它使用密码字段来验证用户。在本地,它按预期工作,工作流程进入下一步。当我在IIS服务器中部署代码时,我无法使密码功能工作。与数据库的连接字符串正在工作,因为我能够将数据保存到数据库。 我添加了示例代码。

    public ActionResult Authenticate(string password)
    {
        try
        {
            IdentityTheftEntities context = new IdentityTheftEntities();
            Admin user = context.Admins.Where(x => x.Password == password && x.IsActive == true).FirstOrDefault();
            if (user != null)
            {
                Session.Add("userID", user.ID);
            }
            else
            {
                ViewBag.errorMessage = "Please put correct password!";
                return View("requests");
            }
        }
        catch (Exception ex)
        {

            ViewBag.errMes = ex.Message.ToString();
        }
        return RedirectToAction("requests", "home"); ;
    }

@if (Session["userID"] != null)检查有效性。 当我输入密码并点击提交时没有任何反应。

0 个答案:

没有答案