JSONNetResult.cs 696 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. using Microsoft.AspNetCore.Mvc;
  6. using Microsoft.AspNetCore.Http;
  7. using Newtonsoft.Json.Linq;
  8. namespace SupplierWeb.Commonss
  9. {
  10. public class JSONNetResult : ActionResult
  11. {
  12. private readonly JObject _data;
  13. public JSONNetResult(JObject data)
  14. {
  15. _data = data;
  16. }
  17. public async override void ExecuteResult(ActionContext context)
  18. {
  19. var response = context.HttpContext.Response;
  20. response.ContentType = "application/json";
  21. await response.WriteAsync(_data.ToString(Newtonsoft.Json.Formatting.None));
  22. }
  23. }
  24. }