我在mvc api
中创建了一个返回字符串的方法。但是,我想要返回Json Object
而不是字符串。以下是我的代码。
[AllowAnonymous]
[HttpPost]
[Route("resetpassword")]
public IHttpActionResult ResetPassword(string email)
{
CreateUserAppService();
string newPassword =_userAppService.ResetPassword(email);
string subject = "Reset password";
string body = @"We have processed your request for password reset.<br/><br/>";
string from = ConfigurationManager.AppSettings[Common.Constants.FromEmailDisplayNameKey];
body = string.Format(body, newPassword, from);
SendEmail(email, subject, body, string.Empty);
return Ok<string>(newPassword);
}
这里返回 Ok<string>(newPassword);
。现在我想返回一个 Json对象
。我该如何返回 Json对象?
return Json(new {success = true});
的操作。 - incutonez