Overload UriHelper to forceLoad the page even if it's not a Blazor defined Route. #1154
Conversation
/// <param name="forceLoad">Indicator to force load the URI, even if it's not a blazor route.</param> I definitely find A few candidates:
|
Not to be nitpicky, but if "byPassInternalRouting" is used, could we correctly name it "bypassInternalRouting" bypass is one word. |
Where can we use enhancement like this? Probably there are two places: For completeness |
I was also thinking to simply not use the location.href = uri; This is basically what we're doing setting the location, since it is a hard reload of the page. |
@SteveSandersonMS any opinion on this? So I can prepare it for the 0.5.0 if you'd like. |
@vertonghenb Thanks for contributing this! We won't get it in in time for 0.5.0 (there's quite a bit to review and some API decisions to make) but we should be able to merge to |
Sure, if the API decision is made, i'll assist further. |
From my personal experience, Using <a onclick=@(()=>Navigate("/login")) href="#">Login</a> window.Refresh = (a) => {
location.reload();
return true;
} async void Navigate(string uri)
{
UriHelper.NavigateTo(uri);
await JSRuntime.Current.InvokeAsync<bool>("Refresh");
} |
@SteveSandersonMS something for 0.6.0? |
Anything new yet? Will it be included in version 0.7.0? |
Thanks again for this, @vertonghenb! It's now moved to dotnet/aspnetcore#4786, where it will be merged shortly. |
PR issued to solve
Basically when you have a MVC Server that serves the Blazor Client and on the other hand sends File Downloads (for example). It was not possible to load the MVC Uri outside of Blazor's internal routing.
With this PR, it's now possible to use the following block of code to load a Uri outside of Blazor's routing:
Tests
Not really sure how to test this in the current suite, maybe add an additional AspNetHosted project with
a server that also serves via MVC? I simply tested on "my machine" to make sure it's loading the page.
Caveats
The mapping of the controllers still have to happen on Startup.cs (which is normal):
Impact
No impact on current usages of IUriHelper (default parameter)
If you know a better name for the parameter, I'm all ears!