How to add implementation of IUriHelper
service to Startup.cs in Blazor?
IUriHelper
is now NavigationManager
. See Get current Url in a Blazor component for details.
You can inject and use NavigationManager
at Shared/NavMenu.cshtml
without issues. You don't need any expecial, you don't need to add NavigationManager
at app startup, it's already injected. Sample:
Shared/NavMenu.cshtml:
@inject NavigationManager NavigationManager
<div class="top-row pl-4 navbar navbar-dark">
<a class="navbar-brand" href="">
@(NavigationManager.Uri) @* <--- sample using it --- *@
</a>
<button class="navbar-toggler" @onclick="ToggleNavMenu">
<span class="navbar-toggler-icon"></span>
</button>
</div>
Result:
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With