Search code examples
c#asp.net-core-webapiservicestack.net-7.0

.Net 7 ServiceStack 6.4 breaking api route that has just "/api"


Trying to provide more info and not sure how much is relevant. One of our webapi is deployed to IIS : abcdomain.com/xyzweb. We started upgrading our env to .net 7 from .net 5. Web api also uses ServiceStack 6.4.

One of the route defined in the c# Webapi, ServiceStack plugin is "/api". Until recently requests to endpoint abcdomain.com/xyzweb/api was fine. But now (.net 7 upgrade?) we noticed that the calls to endpoint does not reach the (http get/post method) handler. We have a small middleware defined in startup.cs configure method and see the execution flow through the middleware code when the abcdomain.com/xyzweb/api request is made and the middleware ends by calling next() and after which execution flow lost (webapi is still live).

After much trials, something I read but could not put my fingers on the content, went ahead and changed the route definition to "/apihello" instead of "/api" and then the requests started working as before.

Any pointers what made it break or what made it work?

Searching is difficult with "api", brings only irrelevant results.

I would like to add that before changing /api to /apihello, the http request would return HTTP status 200 (though it did not go to the handler) and Raw response "Error: System.NotImplementedException: The operation '' does not exist for this service".


Solution

  • Let me begin by answering that @mythz suggestion according to JSON /api predefined resolved the issue. But I am hesitant to accept that as an answer.

    1. The http request should not respond with HTTP Status 200 when the execution flow did not even reach my request handler.
    2. Need to add similar assert like AssertOperationExists that explains operationName is empty and that The pre-defined JSON API route expects a URL in the format /api/{RequestDto} instead of Error: System.NotImplementedException: The operation '' does not exist for this service that is of no help.