Skip to content

Instantly share code, notes, and snippets.

@jgable
Created February 10, 2012 20:12
Show Gist options
  • Save jgable/1792393 to your computer and use it in GitHub Desktop.
Save jgable/1792393 to your computer and use it in GitHub Desktop.
AllowJsonGetAttribute for .Net MVC
// Originally from RealWorldWpDev.codeplex.com : @matthidinger
using System.Web.Mvc;
public class AllowJsonGetAttribute : ActionFilterAttribute
{
public override void OnResultExecuting(ResultExecutingContext filterContext)
{
var result = filterContext.Result as JsonResult;
if(result != null)
{
result.JsonRequestBehavior = JsonRequestBehavior.AllowGet;
}
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment