ASP.NET MVC 2.0 JsonRequestBehavior Global Setting
Posted
by beckelmw
on Stack Overflow
See other posts from Stack Overflow
or by beckelmw
Published on 2009-11-02T19:37:47Z
Indexed on
2010/04/27
1:13 UTC
Read the original article
Hit count: 705
ASP.NET
|asp.net-mvc-2
ASP.NET MVC 2.0 will now, by default, throw an exception when an action attempts to return JSON in response to a GET request. I know this can be overridden on a method by method basis by using JsonRequestBehavior.AllowGet, but is it possible to set on a controller or higher basis (possibly the web.config)?
Update: Per Levi's comment, this is what I ended up using-
protected override JsonResult Json(object data, string contentType, System.Text.Encoding contentEncoding)
{
return Json(data, contentType, JsonRequestBehavior.AllowGet);
}
© Stack Overflow or respective owner