Validation MVC5挂起签名Manager.PasswordSignIn(和异步)
下面的代码只挂在服务器上,不挂在任何本地开发人员中。我们正在我的应用程序失败的阶段环境中成功连接到测试数据库 我正在对AccountController的登录方法进行Ajax调用 为了对服务器进行故障排除,我将这个控制器简化为login方法,并返回一个非常简单的视图 调用(Ajax): 我已验证模型中发送的信息是否正确。这意味着我收到了电子邮件和密码(而不是用户名) 这在运行iis 7.5的我的后台服务器或生产服务器上都不起作用 我刚挂了一页。。。为什么不退出SignInManager.PasswordSignIn方法并继续返回部分视图 编辑/更新:Validation MVC5挂起签名Manager.PasswordSignIn(和异步),validation,asp.net-mvc-5,Validation,Asp.net Mvc 5,下面的代码只挂在服务器上,不挂在任何本地开发人员中。我们正在我的应用程序失败的阶段环境中成功连接到测试数据库 我正在对AccountController的登录方法进行Ajax调用 为了对服务器进行故障排除,我将这个控制器简化为login方法,并返回一个非常简单的视图 调用(Ajax): 我已验证模型中发送的信息是否正确。这意味着我收到了电子邮件和密码(而不是用户名) 这在运行iis 7.5的我的后台服务器或生产服务器上都不起作用 我刚挂了一页。。。为什么不退出SignInManager.Pass
我清除了数据库,并在pmc中运行了用于迁移的更新数据库。它起了一秒钟的作用。当我在装饰我的一个控制器的安全属性中更改角色,然后发布。。。回到绞刑架上。所以你的passwordsignin方法携带了4个参数,1代表你的用户名或你使用的电子邮件,第二代表你的密码,第三是处理持久性的bool,第四也是shouldlockout的bool 不要介意我的解释,试试这个,我希望它对你有用
var result=SignInManager.PasswordSignIn(model.Email,model.Password,false,false) 希望它起作用从来都不是一个好主意。你必须知道它为什么起作用!
@using (Html.BeginForm("Login", "Account", new { ReturnUrl = ViewBag.ReturnUrl }, FormMethod.Post, new { id = "login-Form", @class = "myForm form-horizontal", role = "form" }))
{
<div class="form-group">
@Html.LabelFor(m => m.Email, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.TextBoxFor(m => m.Email, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Email, "", new { @class = "text-danger" })
</div>
</div>
<div class="form-group">
@Html.LabelFor(m => m.Password, new { @class = "col-md-2 control-label" })
<div class="col-md-10">
@Html.PasswordFor(m => m.Password, new { @class = "form-control" })
@Html.ValidationMessageFor(m => m.Password, "", new { @class = "text-danger" })
</div>
</div>
}
<script>
$(function () {
$('#login-Form').ajaxForm({
success: function (result) {
$('#downloadSection').html(result);
$('#dynamicMessage').empty().html('<h1 style="float: left;">You may now download any of the files on the right.</h1>')
},
error: function (request, status, error) {
$('#downloadSection').html("There was an error of type(" + status + "): " + error);
}
});
});
</script>
// POST: /Account/Login
[HttpPost]
[AllowAnonymous]
[ValidateAntiForgeryToken]
public ActionResult Login(LoginViewModel model, string returnUrl)
{
var result = SignInManager.PasswordSignIn(model.Email, model.Password, model.RememberMe, shouldLockout: false);
return PartialView("MyPartialView", "It will never get this far anyway.");
}