默認的404頁我已經寫了具有HandleUnauthorizedRequest
的覆蓋定製AuthorizeAttribute
。這個覆蓋有條件設置響應狀態碼404:如何輸出中HandleUnauthorizedRequest
var response = filterContext.HttpContext.Response;
response.StatusCode = 404;
response.ContentType = null;
response.End();
的問題是,充分反應是:
HTTP/1.1 404 Not Found
Server: ASP.NET Development Server/10.0.0.0
Date: Mon, 24 Jan 2011 16:43:08 GMT
X-AspNet-Version: 4.0.30319
X-AspNetMvc-Version: 2.0
Cache-Control: private
Connection: Close
當我想發回默認的404頁面。喜歡的東西:
我該怎麼辦呢?
僅供參考 - 當重寫HandleUnauthorizedRequest,你真的應該設置filterContext.Result = {}的東西。到Response.End()實際上並不保證停止在MVC管道的要求,你可能會發現你的操作方法實際執行反正。 – Levi