// POST: /Account/ResetPassword [HttpPost] [AllowAnonymous] [ValidateAntiForgeryToken] public async Task<ActionResult> ResetPassword(ResetPasswordViewModel model) { if (!ModelState.IsValid) { return View(model); } var user = await UserManager.FindByNameAsync(model.Email); if (user == null) { // Don't reveal that the user does not exist return RedirectToAction("ResetPasswordConfirmation", "Account"); } var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password); if (result.Succeeded) { return RedirectToAction("ResetPasswordConfirmation", "Account"); } AddErrors(result); return View(); }
var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
这合起来不就是同步执行么。和
var result = UserManager.ResetPassword(user.Id, model.Code, model.Password);
啥区别
区别在于UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);可以不加await
而后面那个必须等待.
var result = await UserManager.ResetPasswordAsync(user.Id, model.Code, model.Password);
这合起来不就是同步执行么。和
var result = UserManager.ResetPassword(user.Id, model.Code, model.Password); 一样效果。对吗?
@王庆东mas: 是的.你等待了.就和同步方法的效果是一样的.