-
Notifications
You must be signed in to change notification settings - Fork 164
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
Duplicate results shown in OData route debug view for conventional and attribute routed routes #428
Comments
@julealgon Typically, don't mix them together. Any reason why did you do like this? I know it's a problem. But, it seems no matter how I implement could not meet all the requirements. |
I'm not completely sure what you mean with "why did you do like this". As you can see from the example, all I have is a single As for context/scenario, I had a v7 sample project and was migrating it to v8 to see what the new features were. Additionally, I was also doing an experiment on migrating a normal MVC API (using the default API project template) to OData and seeing what the potential pain points would be. I think it's very important for the framework to be consistent and predictable in its behavior. IMHO, we are violating the Principle of Least Astonishment right now with the current implementation and this is bad for consumers: it creates confusion, causes people to ask the wrong questions, etc. If the table represents "routes", then it makes zero sense to have multiple entries for the same route: they are semantically the "same route" anyways. From this perspective, it doesn't really matter "who discovered the route", only that "the route was discovered".
I don't know the internals enough to understand why you think it can't be implemented in a way that meets all requirements, so if you could clarify on the challenges that would be great. Having said that, this issue in particular is in regards to the presentation of the matches, and not necessarily about the matches themselves. The main problem here is that routes are presented in an apparently "duplicated" manner. Seeing 100% duplicated data in a table like this is very off-putting. This is why I proposed a couple of ways to fix this presentation problem: either remove the duplicated entry altogether (a Sure, if the discovery mechanism itself guaranteed non-duplicate routes, that would be even better (and I do think that would be the way to go). However, I think this is fixable even without that in place. |
Microsoft.AspNetCore.OData v8.0.5
The OData route debug view currently show matches for all conventions, regardless if they are duplicates. Let's take the default Weather Forecast sample for this.
If we have:
Then the debug view correctly lists
![image](https://user-images.githubusercontent.com/461579/148779511-40443665-a065-410c-8290-dc5d78018429.png)
GET Forecasts
only once:However, if I change the method name from
Whatever
toGet
, it will now show the exact same route twice (due to now matching both via convention, and attribute routing):The application works correctly in both cases, resolving the GET action to the same method. The way the routes are displayed in the debug view, however, is fairly confusing. IMHO, this should be fixed in one of 2 ways:
1 seems simpler to me, but 2 might be of help for debugging purposes.
FYI, the exact same behavior is present for all other route types and verbs: as long as they are attribute routed and match the naming convention at the same time, they appear twice. I used the
GET entityset
here as an example only.The text was updated successfully, but these errors were encountered: