servicestack,single-page-application,servicestack-razor,Razor,Asp.net Core,servicestack,Single Page Application,Servicestack Razor" /> servicestack,single-page-application,servicestack-razor,Razor,Asp.net Core,servicestack,Single Page Application,Servicestack Razor" />

Razor 具有多个水疗中心的ServiceStack剃须刀

Razor 具有多个水疗中心的ServiceStack剃须刀,razor,asp.net-core,servicestack,single-page-application,servicestack-razor,Razor,Asp.net Core,servicestack,Single Page Application,Servicestack Razor,我没有看到在互联网上将ServiceStack Razor与多个水疗中心一起使用的例子。在我的用例中有多个SPA的原因是因为我的整个站点非常庞大,我想用多个SPA模块化我的站点。我知道FallbackRoute属性,但根据文档,它似乎只允许一个FallbackRoute?例如,我希望在我的应用程序中有这些路由到各自的SPA www.mydomain.com/spa1/ www.mydomain.com/spa2/ www.mydomain.com/spa3/ 有没有人举过这种架构的例子?如果

我没有看到在互联网上将ServiceStack Razor与多个水疗中心一起使用的例子。在我的用例中有多个SPA的原因是因为我的整个站点非常庞大,我想用多个SPA模块化我的站点。我知道FallbackRoute属性,但根据文档,它似乎只允许一个FallbackRoute?例如,我希望在我的应用程序中有这些路由到各自的SPA

  • www.mydomain.com/spa1/
  • www.mydomain.com/spa2/
  • www.mydomain.com/spa3/

有没有人举过这种架构的例子?如果它也在.NET核心体系结构中,则最好只返回回退路线中每个不同路线所需的相应SPA主页,例如:

[FallbackRoute("/{PathInfo*}")]
public class FallbackForClientRoutes
{
    public string PathInfo { get; set; }
}

public class MyServices : Service
{
    //Return SPA index.html for unmatched requests so routing is handled on client
    public object Any(FallbackForClientRoutes request)
    {
        if (request.PathInfo.StartsWith("/spa1"))
            return new HttpResult(VirtualFileSources.GetFile("spa1/index.html"));
        if (request.PathInfo.StartsWith("/spa2"))
            return new HttpResult(VirtualFileSources.GetFile("spa2/index.html"));
        if (request.PathInfo.StartsWith("/spa3"))
            return new HttpResult(VirtualFileSources.GetFile("spa3/index.html"));

        throw new NotSupportedException("Unknown Route: " + request.PathInfo);
    }
}

只需返回回退路线中每个不同路线所需的相应SPA主页,例如:

[FallbackRoute("/{PathInfo*}")]
public class FallbackForClientRoutes
{
    public string PathInfo { get; set; }
}

public class MyServices : Service
{
    //Return SPA index.html for unmatched requests so routing is handled on client
    public object Any(FallbackForClientRoutes request)
    {
        if (request.PathInfo.StartsWith("/spa1"))
            return new HttpResult(VirtualFileSources.GetFile("spa1/index.html"));
        if (request.PathInfo.StartsWith("/spa2"))
            return new HttpResult(VirtualFileSources.GetFile("spa2/index.html"));
        if (request.PathInfo.StartsWith("/spa3"))
            return new HttpResult(VirtualFileSources.GetFile("spa3/index.html"));

        throw new NotSupportedException("Unknown Route: " + request.PathInfo);
    }
}