I create a project Blazor (ASP.NET Core hosted) and inject IUriHelper in index.cshtml but is not accessible.
I try
@page "/"
@inject Microsoft.AspNetCore.Blazor.Services.IUriHelper UriHelper
and
@page "/"
@inject IUriHelper UriHelper
Are you getting a compiler error? Or is it null?
````
Severity Code Description Project File Line Suppression State
Error CS0246 The type or namespace name 'IUriHelper' could not be found (are you missing a using directive or an assembly reference?) WebApplication1.Client C:\dev\WebApplication1\WebApplication1.Client\Pages\Index.cshtml 1 Active
Error CS0246 The type or namespace name 'IUriHelper' could not be found (are you missing a using directive or an assembly reference?) WebApplication1.Client C:\dev\WebApplication1\WebApplication1.Client\Pages\Index.cshtml 1 Active
Error CS0246 The type or namespace name 'IUriHelper' could not be found (are you missing a using directive or an assembly reference?) WebApplication1.Client C:\dev\WebApplication1\WebApplication1.Client\Pages\Index.cshtml 2 Active
```
is a new application with only the line @inject IUriHelper UriHelper
The namespace has changed:
@inject Microsoft.AspNetCore.Components.Services.IUriHelper UriHelper
it's works!
Has it changed again again? :D
Yes — the namespace no longer ends with .Services
.
Try the interface: Microsoft.AspNetCore.Components.IUriHelper
Has it changed again again again? 😕
Yes, it’s called NavigationManager now. https://devblogs.microsoft.com/aspnet/asp-net-core-and-blazor-updates-in-net-core-3-0-preview-9/
Most helpful comment
Yes, it’s called NavigationManager now. https://devblogs.microsoft.com/aspnet/asp-net-core-and-blazor-updates-in-net-core-3-0-preview-9/