Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[ASP.NET Core] Fix missing http.route for requests outside of MVC #4104
[ASP.NET Core] Fix missing http.route for requests outside of MVC #4104
Changes from 1 commit
821b1b0
0e12ed7
bd7f6e0
517e4c1
af0f9df
ad11484
7c31a1b
f99f33a
37607e9
7361079
c33d201
fa133f2
8527767
dfd7774
a966577
15cde25
f9f7607
32f71a6
99f9396
2a5a6fe
ef166a9
File filter
Filter by extension
Conversations
Jump to
There are no files selected for viewing
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've tried things out on an MVC app before and after this PR. I think we need to consider the test matrix a bit before going forward with this PR.
Below is abbreviated output from the console exporter highlighting the important differences. Three endpoints are exercised:
Two things of note:
http.route
attribute is set, it too is the same for all of the endpoints - I'm not sure if this is a simply a limitation due to the type of routing I'm using, or if there's a way we can get the actual controller/action of the route in thehttp.route
.Before
Activity.DisplayName: /
Activity.Tags:
http.target: /
http.url: http://localhost:5199/
Activity.DisplayName: /Home/Index
Activity.Tags:
http.target: /Home/Index
http.url: http://localhost:5199/Home/Index
Activity.DisplayName: /Home/Privacy
Activity.Tags:
http.target: /Home/Privacy
http.url: http://localhost:5199/Home/Privacy
After
Activity.DisplayName: {controller=Home}/{action=Index}/{id?}
Activity.Tags:
http.target: /
http.url: http://localhost:5199/
http.route: {controller=Home}/{action=Index}/{id?}
Activity.DisplayName: {controller=Home}/{action=Index}/{id?}
Activity.Tags:
http.target: /Home/Index
http.url: http://localhost:5199/Home/Index
http.route: {controller=Home}/{action=Index}/{id?}
Activity.DisplayName: {controller=Home}/{action=Index}/{id?}
Activity.Tags:
http.target: /Home/Privacy
http.url: http://localhost:5199/Home/Privacy
http.route: {controller=Home}/{action=Index}/{id?}
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Just a quick brainstorm of the various routing use cases we might need coverage for.
I'm not suggesting we need coverage for all these things in this PR, but given that routing is so complex, I think it'd be nice to be able to have a table to be able to point to that makes it clear what to expect when using different styles of routing. Something like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@alanwest - Have updated PR description. I think the case you had #4104 (comment) is conventional routing
We could have these added to test
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
With this PR if
/Home/Privacy
maps to{controller=Home}/{action=Index}/{id?}
with conventional routing, then I think we should resolve this before merging.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It looks like you have expected behavior.
I haven't run your tests, but I guess you're getting one route for http://localhost:5199/ and http://localhost:5199/Home/Index and http://localhost:5199/Home/Privacy because they all match to the same conventional route. That's how conventional routing works: an app centrally specifies just a few route patterns, then those patterns match to multiple controllers and actions.
The pattern
{controller=Home}/{action=Index}/{id?}
will take any URL with 0-3 segments, e.g./
,/Home/Index
,/Home/Privacy
, and match the controller/action to controllers and actions in your app.You could add some customization like replacing
controller
,action
andpage
parameters with values fromRouteData
. That might be more useful, but it wouldn't be the original template anymore.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks @JamesNK for reviewing this. We have a similar issue with API versioning #4525. Where the template has same value for different API versions. Would that one also require some customization?