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

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -