The content method is protected internally, so you cannot use it outside the controller. Controller.Content Method . Most likely, your static class violates the SRP principle. Let him do his work (initialization, serialization, ...) and the task of the controller - the controller - returns the result to the client.
protected internal ContentResult Content(string content)
It would seem something like:
public static class MyHelper { public static object GetAlbum(AlbumVO album) { return new { max_car = @ABookClient.maxCharsProjecName, trans_img = @ABookClient.Transparent_Image, show_description = @ABookClient.Show_Product_Description, product_type = "Album", obj = CreateObjAlbumVO(album), }; } } public class AlbumController : Controller { public ActionResult GetAlbums(int id) { var album = Context.GetAlbum(id); var convertedResult = MyHelper.GetAlbum(album); return Json(convertedResult); } }
I would also suggest taking a look at AutoMapper to create client response objects.
source share