将Razor RockStars移植到ServiceStack V4

nov*_*ver 6 servicestack

我目前正在研究github 上的Razor Rockstars示例项目,试图了解ServiceStack V4和Razor是如何粘合在一起的.

我特别在SS Razor演示中遇到以下代码:

SetConfig(new EndpointHostConfig {
           CustomHttpHandlers = {
                { HttpStatusCode.NotFound, new RazorHandler("/notfound") },
                { HttpStatusCode.Unauthorized, new RazorHandler("/login") },
            }
        });
Run Code Online (Sandbox Code Playgroud)

我从文档中得知EndpointHostConfig现在只是HostConfig,但我似乎无法在Service Stack V4发行说明中找到CustomHttpHandlers .有什么明显的东西我不见了吗?

提前致谢.

myt*_*thz 5

HostConfig仅限于配置,在v4中,以前在Config中的大多数处理程序已被移动到AppHost,例如:

this.CustomErrorHttpHandlers[HttpStatusCode.NotFound] = new RazorHandler("/notfound");
this.CustomErrorHttpHandlers[HttpStatusCode.Unauthorized] = new RazorHandler("/login");
Run Code Online (Sandbox Code Playgroud)