asp.net mvc 4 - IHttpActionResult return Json object -
i have created 1 method in mvc api
returns string. instead of returning string
, want return json object
. here code.
[allowanonymous] [httppost] [route("resetpassword")] public ihttpactionresult resetpassword(string email) { createuserappservice(); string newpassword =_userappservice.resetpassword(email); string subject = "reset password"; string body = @"we have processed request password reset.<br/><br/>"; string = configurationmanager.appsettings[common.constants.fromemaildisplaynamekey]; body = string.format(body, newpassword, from); sendemail(email, subject, body, string.empty); return ok<string>(newpassword); }
here returns ok<string>(newpassword);
want return json object
. how can return json object?
try that:
[allowanonymous] [httppost] [route("resetpassword")] public ihttpactionresult resetpassword(string email) { //... return json(newpassword); }
Comments
Post a Comment