JsonNetController.cs 731 B

1234567891011121314151617181920212223242526
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using System.Web.Mvc;
  6. namespace Bowin.Common.Mvc
  7. {
  8. public class JsonNetController : Controller
  9. {
  10. protected override JsonResult Json(object data, string contentType, Encoding contentEncoding, JsonRequestBehavior behavior)
  11. {
  12. if (behavior == JsonRequestBehavior.DenyGet && string.Equals(this.Request.HttpMethod, "GET", StringComparison.OrdinalIgnoreCase))
  13. return new JsonResult();
  14. return new JsonNetResult()
  15. {
  16. Data = data,
  17. ContentType = contentType,
  18. ContentEncoding = contentEncoding
  19. };
  20. }
  21. }
  22. }