-
Notifications
You must be signed in to change notification settings - Fork 9.8k
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
Shareable string constant as route template #15665
Comments
Thanks for suggesting this. I've added this requirement to our tracking issue at #5489. In the meantime I'd recommend just duplicating the strings, as there isn't a straightforward way to share them. |
So I'm experiencing something super duper weird over here... Things have been working just fine until I made a new page... Now I'm getting this: Error: System.InvalidOperationException: Failed to compare two elements in the array. ---> System.InvalidOperationException: The following routes are ambiguous: And this is the page it's complaining about: As you can see, there is only one page declaration. She also only has one page declaration? WTF |
Hi @McHeff. If you think you've discovered a bug, please file an issue on the https://github.com/aspnet/aspnetcore repo. Now that the Blazor code is part of the main ASP.NET Core repo, we no longer use this repo for Blazor issues. |
Sure thing @danroth27, it's really weird because this only happens sometimes... Like I have many razor views in my app, most of them have lambda expressions and nested for loops, but only on this new page did I get ambiguous page route errors... On another page, I got that error when I put some binding on my HTML control. Lol, will file an issue now (y) |
In Case anyone also stumble across this issue. |
Blazor project (ASP.NET Core hosted) (client project) v 0.5.1.
I wanted to create shareable route templates.
Solution 1 - reference string constant in page:
@page UiPaths.Account
to Account.cshtml.Issue 1
Solution 2 - create code behind class:
Issue 2
The application throws exception in runtime:
Error: System.InvalidOperationException: Failed to compare two elements in the array. ---> System.InvalidOperationException: The following routes are ambiguous:
'account' in 'BlazorInNetFW.Client.Pages.Account'
'account' in 'BlazorInNetFW.Client.Pages.AccountPageCodeBehind'
The problem is ComponentResolver is static class instead of replaceable service and it finds code behind class as a regular component. Then RouteTable creates RouteEntry even for the code behind class.
If I understand correctly, only possible solution here is to create and use custom router (instead of Microsoft.AspNetCore.Blazor.Routing.Router). However, I think it would be better if it's possible to maintain route paths/templates in configurable way (possibly even paths taken from a DB) instead of custom Router. Could you provide your opinion and outline code changes (if any), please?
The text was updated successfully, but these errors were encountered: