-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Attribute Routing: Implement ~/
for overriding a prefix
#732
Comments
I've used HttpGet as a sample, same applies to other verbs. I'm going to start by implementing everything as override and making AttributeRouteTemplate.Combine strip the " Also we need to figure out how "~/" plays with areas. Whether it should override the area or not. @rynowak Thoughts? |
Discussed offline: No need to think of areas for this. |
Still good question about Plus there's a reasonable extensibility scenario here. I'm a user, and I implement a global prefix for routes as a convention (using |
As per discussion offline, we are making "/" and "~/" will expose the same behavior (both will override the value in [Route(...)] The semantics on the table above will be the same for both values |
This change allows a user to override a route prefix set using [Route("...")] on the controller by providing a route template on the action that starts with "~/" or "/". For example, [HttpGet("~/...")] or [HttpGet("/...")] If the user specifies a template in [Route] that starts with "~/" or "/", we will just strip the prefix from the template and use the remaining part of the template. The reason to do this is that there's a reasonable extensibility scenario where a user can implement a global prefix for routes as a convention (using IReflectedApplicationModelConvention), and use ~/ to escape that prefix (just like we support with action-level routes).
@yishaigalatzer @rynowak take a look at the PR |
This change allows a user to override a route prefix set using [Route("...")] on the controller by providing a route template on the action that starts with "~/" or "/". For example, [HttpGet("~/...")] or [HttpGet("/...")] If the user specifies a template in [Route] that starts with "~/" or "/", we will just strip the prefix from the template and use the remaining part of the template. The reason to do this is that there's a reasonable extensibility scenario where a user can implement a global prefix for routes as a convention (using IReflectedApplicationModelConvention), and use ~/ to escape that prefix (just like we support with action-level routes).
This change allows a user to override a route prefix set using [Route("...")] on the controller by providing a route template on the action that starts with "~/" or "/". For example, [HttpGet("~/...")] or [HttpGet("/...")] If the user specifies a template in [Route] that starts with "~/" or "/", we will just strip the prefix from the template and use the remaining part of the template. The reason to do this is that there's a reasonable extensibility scenario where a user can implement a global prefix for routes as a convention (using IReflectedApplicationModelConvention), and use ~/ to escape that prefix (just like we support with action-level routes).
This change allows a user to override a route prefix set using [Route("...")] on the controller by providing a route template on the action that starts with "~/" or "/". For example, [HttpGet("~/...")] or [HttpGet("/...")] If the user specifies a template in [Route] that starts with "~/" or "/", we will just strip the prefix from the template and use the remaining part of the template. The reason to do this is that there's a reasonable extensibility scenario where a user can implement a global prefix for routes as a convention (using IReflectedApplicationModelConvention), and use ~/ to escape that prefix (just like we support with action-level routes).
commit 87c430a |
An attribute route starting with
~/
overrides any value set on the controller with[Route(...)]
.Need to modify the code that joins templates + add tests.
The text was updated successfully, but these errors were encountered: