我有一個網站使用南希使用OWIN託管。無法在OWIN上顯示Nancy的自定義錯誤頁面
在我Startup.cs文件I定義PassThroughOptions如下:
public void Configuration(IAppBuilder app)
{
app.UseNancy(o => {
o.PassThroughWhenStatusCodesAre(
HttpStatusCode.NotFound,
HttpStatusCode.InternalServerError
);
o.Bootstrapper = new Bootstrapper();
});
app.UseStageMarker(PipelineStage.MapHandler);
}
我需要直通的NOTFOUND要求,使物像我捆綁.LESS文件或miniprofiler,結果或靜態文件在我的網站的根目錄(robots.txt或sitemap.xml)中工作。
我也有一個404代碼的自定義StatusCodeHandler,它也檢查自定義頭來區分靜態文件(或.less bundles/miniprofiler)和我的模塊方法中找不到的實際東西。
public void Handle(HttpStatusCode statusCode, NancyContext context)
{
Log.Warn("Not found: " + context.Request.Url);
base.Handle(statusCode, context, "Errors/NotFound");
}
這個處理程序然後應該實際顯示錯誤頁面。
protected void Handle(HttpStatusCode statusCode, NancyContext context, string view)
{
var response = new Negotiator(context)
.WithModel(GetErrorModel(context))
.WithStatusCode(statusCode)
.WithView(view);
context.Response = responseNegotiator.NegotiateResponse(response, context);
}
但是錯誤頁面從不顯示。該請求被處理了三次,最終顯示了默認的IIS錯誤頁面(對於httpErrors使用errorMode =「Custom」)或簡單的白頁(對於httpErrors使用existingResponse =「PassThrough」)。
當在OWIN上託管南希網站時,是否有任何方式顯示如自定義錯誤頁面這樣簡單的內容?