使用jQuery显示我的HttpStatusCodeResult错误描述

时间:2014-08-07 15:35:45

标签: javascript jquery razor

我的自定义授权类中包含以下内容: -

protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
        {if (filterContext.HttpContext.Request.IsAjaxRequest())
            {
                filterContext.Result = new HttpStatusCodeResult(403, "json permission denied");
               }

并使用jquery我可以捕获错误代码如下: -

$(document).ajaxError(function (e,xhr,textStatus, errorThrown) {
        if (xhr.status == 401)
            window.location = "/Account/Login";
        else if (xhr.status == 403)
            jAlert(xhr.staus, "You have no enough permissions to request this resource.");
    });

但我不确定如何捕获错误消息" json权限被拒绝"

0 个答案:

没有答案