1

Im migrating my code to a core application.

So far so good. i got it all running, but there is one problem.

I had a ui (with razor) and using the CatchAllHandlers. And for the api i used HandlerFactoryPath to prefix the urls.

Now i have 2 problems:

  • It seems CatchAllHandlers isn't used?
  • Route is only processed if route starts with HandlerFactoryPath?

The second issue is fixable but how would i go around the first one?

Do i make my own middle-ware or does servicestack support other ways of doing this?

Joel Harkes
  • 10,975
  • 3
  • 46
  • 65
  • When i remove the HandlerFactoryPath the catchall routing seems to work – Joel Harkes Nov 16 '16 at 14:22
  • Im trying to render a partial now using: http://stackoverflow.com/a/39400153/1275832 (inside a subclass of ss.mvc.viewPage. but this keeps throwing me errosr now – Joel Harkes Nov 16 '16 at 14:23

1 Answers1

1

CatchAllHandlers are executed in .NET Core, it's also what ServiceStack's new MVC RazorFormat uses to process Content Pages.

Specifying a HandlerFactoryPath, e.g:

SetConfig(new HostConfig {
    HandlerFactoryPath = "api"
});

Tells ServiceStack that you only want to listen to requests from the /api path info. All other requests are passed through ServiceStack who calls the next module in .NET Core pipeline as per .NET Core's convention when it's not configured to handle a route.

Not sure if it's relevant to your solution but in ServiceStack .NET Core you can register a ServiceStack Handler in .NET Core module pipeline so you could for instance return a /default.cshtml Content Razor Page for each request that's not handled by ServiceStack, by registering it after ServiceStack:

app.UseServiceStack(new AppHost());

app.Use(new RazorHandler("/default"));
mythz
  • 141,670
  • 29
  • 246
  • 390