DS7/DSWeb/TruckMng/Helper/JsonRequestBehaviorAttribut...

25 lines
606 B
C#

using System.Web.Mvc;
namespace DSWeb.TruckMng.Helper
{
public class JsonRequestBehaviorAttribute : ActionFilterAttribute
{
private JsonRequestBehavior Behavior { get; set; }
public JsonRequestBehaviorAttribute()
{
Behavior = JsonRequestBehavior.AllowGet;
}
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
var result = filterContext.Result as JsonResult;
if (result != null)
{
result.JsonRequestBehavior = Behavior;
}
}
}
}