我的自定义授权类中包含以下内容: -
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权限被拒绝"