tags:

views:

48

answers:

0

Hi,

My question is similar to this post, http://stackoverflow.com/questions/109883/how-to-return-json-from-a-handleerror-filter. I've tried to return Json from a custom HandleError, so I use filterContext.Result to return Json to show an error message, but it gives me a Http500 error. My code is here.

Any ideas?

public class HandleJsonError : HandleErrorAttribute
{
   public override void OnException(ExceptionContext filterContext)
   {
     base.OnException(filterContext);
     filterContext.Result = new JsonResult()
     {
        Data = {Message="Error"}
     };
   }
}

Thanks in advance
yokyo.