Aspnetcore: @inject IUriHelper in Client side isn't working in Blazor 0.8

Created on 13 Feb 2019  Â·  9Comments  Â·  Source: dotnet/aspnetcore

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

Most helpful comment

All 9 comments

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? 😕

Was this page helpful?
0 / 5 - 0 ratings