【发布时间】:2012-07-31 07:35:44
【问题描述】:
我正在开发一个 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;
}
此代码会从浏览器显示未经授权的请求页面,但我想要的是显示我设计的自定义页面。我该怎么做?
【问题讨论】:
标签: asp.net authorization asp.net-web-api custom-error-pages