public async Task <IActionResult> SendSMSAsync() { if (!_signInManager.IsSignedIn(User)) { return(Json(new { succeeded = false, message = "未登录" })); } var user = await _userManager.GetUserAsync(User); if (user == null) { return(Json(new { succeeded = false, message = "发生未知错误" })); } var token = await _userManager.GenerateChangePhoneNumberTokenAsync(user, user.PhoneNumber); try { await _smsSender.SendValidationCodeAsync(user.PhoneNumber, token); return(Json(new { succeeded = true, message = "短信发送成功" })); } catch (SmsException ex) { return(Json(new { succeeded = false, message = ex.Message })); } catch { return(Json(new { succeeded = false, message = "发生未知错误" })); } }