3

如果我的 ServiceStack 应用程序遇到未处理的异常并返回 HTTP-500,我想自定义显示的错误页面。

我正在使用 ServiceStack.Razor ( http://razor.servicestack.net/ ) 并尝试按照他们的示例进行操作(请参阅在代码中轻松配置自定义错误页面)。这是我尝试过的:

应用主机.cs:

SetConfig(new EndpointHostConfig
{
    CustomHttpHandlers = {
        { HttpStatusCode.InternalServerError, new RazorHandler("/ErrorInternal") }
    }
});

视图/ErrorInternal.cshtml:

An error has occured.

但我仍然得到标准的 ServiceStack 错误页面“...的快照由 ServiceStack 在...上生成”。

4

1 回答 1

1

The cshtml pages under the views folder are used to provide an HTML representation of your response DTOs. What you probably want are the "Dynamic pages without Controllers" for a 500 error. Move your ErrorInternal.cshtml to the root folder of your solution and your "/ErrorInternal" hander should work.

于 2012-12-29T11:02:03.343 回答