public JsonResult GetValidateCodeForForgetPwd(string userName, string email) { var result = new ResponseResult(); try { var user = new UserService().GetUserByUserName(userName); if (user.Email != email) { result.Success = false; result.Message = MessageConst.USER_EMAIL_USERNAME_NOT_MATTCHING; } else { //生成随机验证码 var code = RandomUtil.GetRandomCode(6); // 发送邮件 SendEmail(email, code); // 保存至数据库 new UserExtensionService().SaveValidateCode(userName, code); } } catch (Exception ex) { result.Success = false; result.Message = MessageConst.System_Error; _logger.Info(ex); } return(Json(result)); }