[C#-MVC] JSONAttribute
C# - JSON Result
public class JSONAttribute : ActionFilterAttribute { public override void OnActionExecuted(ActionExecutedContext filterContext) { var result = new JsonResult(); result.Data = ((ViewResult)filterContext.Result).Model; result.JsonRequestBehavior = JsonRequestBehavior.AllowGet; filterContext.Result = result; } }
//TEST
[JSON] public ActionResult GetJson() { var data = new { x = 10, b = 20, c = 20 }; return View(data); }//Result{"x":10,"b":20,"c":20}
댓글
댓글 쓰기