당신은 당신이 컨트롤러 또는 perticular 행동에 [권한 부여] 속성을 사용하여 동일한처럼이 속성을 사용할 수 있습니다이
public class CustomAuthorize : AuthorizeAttribute
{
protected override void HandleUnauthorizedRequest(AuthorizationContext filterContext)
{
//you can change to any controller or html page.
//filterContext.Result = new RedirectResult("/Account/Login");
if (filterContext.HttpContext.Request.IsAjaxRequest())
{
string destinationUrl = UrlHelper.GenerateContentUrl(FormsAuthentication.LoginUrl, filterContext.HttpContext);
filterContext.Result = new JavaScriptResult()
{
Script = "window.location = '" + destinationUrl + "';"
};
}
else
{
base.HandleUnauthorizedRequest(filterContext);
}
}
}
같은 속성 [권한 부여]를 사용자 정의 할 수 있습니다. 어떤 라이브러리는 아약스 호출을하는 데 사용하는, 그것은 jQuery를
[CustomAuthorize]
public class UserController : Controller
{
// your actions here
}
또는
public class UserController : Controller
{
[CustomAuthorize]
Public ActionResult Indes()
{
// your code here
}
}
입니까? – ryudice
Jquery 및 일부는 Microsoft HTML 아약스 도우미를 사용하여 – JDBlueAudiS4