我正在尝试为根目录/"设置 RestPath,但它不允许我这样做.它说 RestPath '/' on Type 'MainTasks' is not Valid
I'm trying to set a RestPath for root, '/', but its not allowing me to. Its saying RestPath '/' on Type 'MainTasks' is not Valid
有没有办法允许这样做?我想从根提供资源.
Is there a way to allow this? I'd like to provide a resource from the root.
[Route("/", "GET")] public class MainTasks : IReturn<MainTasksResponse> { } 推荐答案您只能在 / 路径上进行匹配rel="nofollow">ServiceStack 带有 FallbackRoute,例如:
You can only match on the Route / Path in ServiceStack with a FallbackRoute, e.g:
[FallbackRoute("/{Path*}")] public class Fallback { public string Path { get; set; } }这使用通配符来处理每个不匹配的路由(包括/foo/bar).只允许 1 个后备路线.
This uses a wildcard to handle every unmatched route (inc. /foo/bar). Only 1 fallback route is allowed.
还有其他一些方法可以处理默认的根路径/:
There are also a few other ways to handle the default root path /:
更多推荐
使用 ServiceStack 为根路径“/"创建路由
发布评论