ApiVersionProperties set default to v1 #1082
-
I'm trying to incorporate this package into an existing project in a way that would allow me to call my default APIs without using "v1" in my URL, and call the new versions using the api/v{apiVersion}/{controller}/{action} format. I figure my best option would be to use AspNet/WebApi/ByNamespaceWebApiExample to get a working version so I know that I understand the concept correctly, but I get a 400 error when calling my test method because the API isn't being specified. My POST call: I'm using the following routes in my Startup.cs:
and I've added a Route attribute to the V1 "Agreements" controller and created a simple method "Hello" that returns a string so I know if I hit the controller: [Route( "api/Agreements" )] I've also tried creating a "Controllers" folder located outside of any of the V1/V2/V3 folders and have created this same AgreementsController, but with the same result. I found a suggestion online to add a case in the HttpControllerSelector method where if there is no version number being passed in the URL then to have the route default to the V1 route - I'd be open to trying this method, but when I look into the HttpControllerSelector method I'm not sure what I would need to do. Any suggestions would be greatly appreciated! |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment 3 replies
-
Looks similar to this issue https://stackoverflow.com/questions/55416709/asp-net-core-set-default-api-versioning |
Beta Was this translation helpful? Give feedback.
Looks similar to this issue
https://stackoverflow.com/questions/55416709/asp-net-core-set-default-api-versioning