*filterContext.Result = new JsonResult()* in mvc not working properly outside the server
<p><em>filterContext.Result = new JsonResult()</em> in above code(<em>CustomJsonExceptionHandler</em>) does not work properly when I access website from outside the server. </p>

<p>Please see below code, function is throwing an exception. Custom attribute is being used to return the error message to ajax function</p>

<p>controller function</p>

<pre><code>[HttpPost]
[CustomJsonExceptionHandler]
public ActionResult GetList(int month, int year)
{
    throw new ArgumentException("Exception");
    List&lt;Dictionary&lt;string, object&gt;&gt; List = new List&lt;Dictionary&lt;string,object&gt;&gt;()
    return Json(List, JsonRequestBehavior.AllowGet);
}
</code></pre>

<p>Custom error attribute </p>

<pre><code>public class CustomJsonExceptionHandler : HandleErrorAttribute
{

    public override void OnException(ExceptionContext filterContext)
    {
        if (filterContext != null &amp;&amp; filterContext.Exception != null)
        {

            filterContext.ExceptionHandled = true;
            filterContext.HttpContext.Response.StatusCode = 500;
            filterContext.Result = new JsonResult()
            {
                JsonRequestBehavior = JsonRequestBehavior.AllowGet,
                Data = new
                {
                    errorMessage = filterContext.Exception.Message
                }
            };
        }
    }
}
</code></pre>

<p>Please see below code of jquery ajax function </p>

<pre><code>$.fn.GetData = function (month, year) {
    var data = null;
    $.ajax({
        url: '/HomeController/GetList',
        data: { month: month, year: year },
        type: 'POST',
        async: false,
        success: function (Listdata) {
            data = Listdata;
        },
        error: function (xhr) {
            var jsonerror = $.parseJSON(xhr.responseText)
            alert(jsonerror.errorMessage)
        }
    });
    return data;
}
</code></pre>

<p>Please Help !!</p>