aspnet / Routing

[Archived] Middleware for routing requests to application logic. Project moved to https://github.com/aspnet/AspNetCore
Apache License 2.0
272 stars 122 forks source link

Endpointing Routing in 2.2 going to be default? #867

Closed shawnwildermuth closed 5 years ago

shawnwildermuth commented 5 years ago

I'm trying to get my head around the Endpoint routing. I understand why you're introducing it, but it looks like it's going to break some major things (for me, it's /Microsoft/aspnet-api-versioning). I can turn off Endpoint routing, but I am hoping to get some opinions about how we should teach it to new students.

The preview1 announcement makes this interesting pronoucement (emphasis mine):

Endpoint routing now processes HTTP methods, [Consumes(...)], versioning, and other policies that used to be part of MVC’s action selection process.

Do you mean that Endpoint routing will include a versioning story, or do you mean that aspnet-api-versioning will be updated to support it? I ask this as it doesn't sound like aspnet-api-versioning will be ready (except with the case where we turn off Endpoint routing for 2.2). Can anyone confirm this so I can plan. Here is the post where I talked to the aspnet-api-versioning folks:

https://github.com/Microsoft/aspnet-api-versioning/issues/363#issuecomment-428617353

JamesNK commented 5 years ago

If the MVC compatibility version is set to 2.1 or lower then it is not on by default. This is what the default MVC template includes when an MVC project is created. By choosing to set the compatibility flag to 2.2 (or latest) you're opting into the latest features, and that means accepting that when you upgrade you may need to change your application to work with the latest MVC features.

If you use a library that builds on the old routing system you will need to disable endpoint routing (there is an explicit flag - MvcOptions.EnableEndpointRouting) until the library supports it.

shawnwildermuth commented 5 years ago

This isn't what I'm getting in Preview2. A new mvc project (dotnet new mvc) has:

services.AddMvc().SetCompatibilityVersion(CompatibilityVersion.Version_2_2);
JamesNK commented 5 years ago

That is what a new 2.2 project will generate. It isn't a breaking change if it is a brand new project! 😄

A 2.1 project will have CompatibilityVersion.Version_2_1 so upgrading to the latest NuGet packages will not automatically enable endpoint routing. The developer must choose to do it.

shawnwildermuth commented 5 years ago

We're on the same page then.

rynowak commented 5 years ago

We've had a few discussions with @commonsensesoftware about this already. Many of the details of the new system works are based on his feedback.. I'm sure we'll work with him to get a release of API versioning that supports the new stuff.

shawnwildermuth commented 5 years ago

Cool, I'm going to see if I can help him with a PR, so we'll have something works by 2.2

rynowak commented 5 years ago

Closing this since its answered