我正在开发一个 ASP.Net Web API 应用程序,并且我使用 AuthorizeAttribute 进行身份验证。当认证失败时,执行的代码就是这个。
protected override void HandleUnauthorizedRequest(HttpActionContext actionContext)
{
HttpContext.Current.Response.AddHeader("AuthenticationStatus", "NotAuthorized");
actionContext.Response = actionContext.Request.CreateResponse(HttpStatusCode.Forbidden);
return;
}
此代码导致从浏览器显示未经授权的请求页面,但我想要的是显示我设计的自定义页面。我怎么做?