C#C
C#4y ago
Anton

ASP.NET Core routing options

Say, I have a single server for some views and some apis, so I'd route views by default, while the api would go under /api. The question is what's the correct way to achieve the routing?
So to be a bit more clear, I want my api controllers resolving to /api/whatever, while all the rest should go to /. I've read the entire page linked above, but it doesn't really mention such a use case, and suggests no best practices in that regard.
Ideally it would be the second option, but the first one also seems fine, if the constant were to be factored out.
Learn how ASP.NET Core MVC uses Routing Middleware to match URLs of incoming requests and map them to actions.
Was this page helpful?