Created
February 10, 2012 20:12
-
-
Save jgable/1792393 to your computer and use it in GitHub Desktop.
AllowJsonGetAttribute for .Net MVC
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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