Can I call a JsonResult method from my ActionResult? What I'm trying to do is to have an Area in my MVC.Site project to deal specifically with API (just return json so that I can reuse with non-mvc projects). And then from a different ActionResult (where I deal with data AND views), I would like to call the JsonResult and then return that Json data along with View information. i.e:
public JsonResult GetSongs()
{
var songs = _music.GetSongs(0, 3);
return Json(new { songs = songs }, JsonRequestBehavior.AllowGet);
}
public ActionResult Songs()
{
// Get the data by calling the JsonResult method
var data = GetSongs();
return Json(new
{
// Render the partial view + data as json
PartialViewHtml = RenderPartialViewToString("MyView", data),
success = true
});
}
Thanks.