i\'m using ASP MVC 5. I have an action in a controller that return a json object:
[HttpGet]
public JsonResult GetUsers()
{
return Json(....., JsonRequestBe
You basically need to write a custom ActionResult that is indicated here in this post
[HttpGet]
public JsonResult GetUsers()
{
JObject someData = ...;
return new JSONNetResult(someData);
}
The JSONNetResult function is:
public class JSONNetResult: ActionResult
{
private readonly JObject _data;
public JSONNetResult(JObject data)
{
_data = data;
}
public override void ExecuteResult(ControllerContext context)
{
var response = context.HttpContext.Response;
response.ContentType = "application/json";
response.Write(_data.ToString(Newtonsoft.Json.Formatting.None));
}
}