我有一个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)
检查有效性。
当我输入密码并点击提交时没有任何反应。