MobileBlazorBindings icon indicating copy to clipboard operation
MobileBlazorBindings copied to clipboard

Shell Navigation does not support parameters in the middle of URL path

Open Dreamescaper opened this issue 4 years ago • 4 comments

STR:

  1. Add ContentPage with @page /users/{Id}/details
  2. Invoke await NavigationManager.GoToAsync($"/users/{userId}/details")

ER: Page is opened.

AR: Exception: Value cannot be null. Parameter name: match.

Changing the URL to something like /user-details/{Id} resolves the issue.

Dreamescaper avatar Feb 14 '21 17:02 Dreamescaper

Tagging @lachlanwgordon .

I think this was a deliberate omission when @lachlanwgordon first added Shell because we thought it better to get something checked in, and resolve everything else whenever it was needed.

I think the main reason we didn't support this is that the route logic is re-implemented in MBB because we were sure if we could re-use Blazor's routing logic (such as parsing, etc.).

If it's possible to re-use Blazor's routing logic, that would be ideal, because it would have 100% fidelity between MBB and the rest of Blazor. If we have to re-implement parsing logic then I want to tread very carefully because I don't want to end up with a huge chunk of copied code, or, worse, code that is re-written but incompatible.

Eilon avatar Feb 16 '21 19:02 Eilon

Here's a meta-issue where @lachlanwgordon enumerated several limitations with what we currently have: https://github.com/dotnet/MobileBlazorBindings/issues/157

But I think it's fine to have this specific issue open for this specific problem.

Eilon avatar Feb 16 '21 19:02 Eilon

I never even thought to try a URL like that, but I'm not at all surprised that it throws an exception.

It's probably not too hard to fix, but unless we urgently need it, let's leave it as-is and try to workout how to use the ASP.Net url parsing.

Thanks for the tip though, I'm going to start using urls like this in web blazor projects.

lachlanwgordon avatar Feb 16 '21 22:02 lachlanwgordon

If it's possible to re-use Blazor's routing logic, that would be ideal, because it would have 100% fidelity between MBB and the rest of Blazor.

Problem is that most of Blazor's routing classes are internal. I'm not sure we'll be able to re-use them. E.g. https://source.dot.net/#Microsoft.AspNetCore.Components/Routing/RouteTableFactory.cs

Dreamescaper avatar Feb 22 '21 23:02 Dreamescaper