I’m trying to add in functionality for adding and removing from a list of items in the UI. The typical way of doing this was to post the form to a controller, add/remove the item, then return the partial view to append to the DOM. When trying to set up an API or MVC controller, the route is not working. I even set up Swagger to try to troubleshoot it, but while Swagger properly finds the controller and route, the route doesn’t actually work.
I can only assume that there is something in Servicestack that is hijacking how routing works. This is a legacy application that we took over and removing Servicestack is not an option. Ultimately, all I want to be able to do is hit a standard controller. If there is a Servicestack way of doing add/remove then I am open to this as well. Thanks.
If this .NET Framework then ServiceStack needs to be hosted at a different path e.g. /api to avoid route conflicts. See docs for running ServiceStack side-by-side with ASP .NET MVC:
Otherwise ServiceStack and MVC should be able to be configured in the same pipeline, you can refer to the mvc project template for an example of a working configuration. Although .NET Core 2.1 is pretty old and out of support so you should look at upgrading first.
This isn’t a path conflict. Attempting to access the controller route results in the 404 page being returned. It seems to me more like the routing is being hijacked somehow by your framework. Using your PathBase code causes the whole system to fail “No webpage was found for the web address”. Is there another setting somewhere I have to update as well? I went through and set the request paths to include the /api route.
If this is .NET Core, all requests are handled by the same middleware request pipeline, so unless you don’t have a wildcard route to handle fallback requests, the requests should be handled by the next middleware in the pipeline.
When using PathBase, all ServiceStack requests should start from there, e.g. /api/metadata.
I just tested my other applications and they work just fine. Am I missing some sort of dependency or something? Let me pull your code off github and use that instead.