Upgrade from v1.0.3 t to v1.1.0 breaks existing routes .NET Core , results in 404 status code
After upgrading an existing .NET Core web api app from v1.0.3 to v1.1.0 w/ not other changes to the project all requests return a 404 error. If the projects is switched back to v1.0.3 everything works correctly. Here is a sample of the versioning attributes where /api/v1/blogposts/1 should reach the action. Setting a breakpoint in the action is never reached.
[ApiVersion("1.0")]
[Route("api/v{version:apiVersion}/blogposts")]
public class BlogPostsController : Controller
{
[HttpGet("{id:int:min(1)}")]
public async Task
Since you said "... w/ not other changes ...", I suspect you have not changed your configuration. The release notes and the wiki documentation outline that you now need to add:
app.UseMvc();
app.UseApiVersioning();
I've tried to make that as obvious as possible. I may consider if there is a way to throw an exception if you have not done so.
Give this change a try and let me know things are still not working.
Yes, that fixed the problem. Thanks.
I don't see anything specifically on this change until I navigate down into the Release Notes. What might be helpful is to include a link at the top of the ReadMe.md and the main page of the Wiki w/ something like "Please read the Release Notes for the latest version when upgrading". Obvious, but given the frequency of upgrades and number of packages in the .NET Core world it can be easy to forget.
Fair. I'll looking into making things more obvious. Glad you got things back up and running
I had the same issue when upgrading from 1.0.3 -> 1.1.0. Confirm that adding app.UseApiVersioning(); fixed the issue. Finally found this post.
Thanks @idevtech and @Alezis. Sorry about the not-so-obviousness. I'm considering some mechanism that will make things fail in a very clear way when you forget to add this new method call. I'm not sure how just yet, but when I figure it out, I'll send out a patch. I'm hoping to eliminate this with ASP.NET Core 2.0, but we'll see. In the meantime, I'd like to minimize the number of times people step on this landmine.