I am capturing errors in a rest call and returning a Json. The error gets written away to a third party logging site.
Something like the following:
var client = new Bugsnag.Client(new Bugsnag.Configuration("KEY"));
client.Notify(new Exception("Error:" + ex.Message ));
return Json(new { success = false, error = ex.Message });
But after this it goes to the global error handling in Application_Error()
protected void Application_Error()
{
var ex = Server.GetLastError();
// ....
}
And it doesn’t capture the error:
This request has been blocked because sensitive information could be disclosed to third party web sites when this is used in a GET request. To allow GET requests, set JsonRequestBehavior to AllowGet
I have to change the last line to
return Json(new { success = false, error = ex.Message }, JsonRequestBehavior.AllowGet);
for it to send the error.
I don’t want to really do this for all the requests.
Is there any setting I can put in web.config
or the like to put in the JsonRequestBehavior
to AllowGet
instead of overriding all my REST call routines as there are hundreds of them?
1