Matblazor: Error: System.InvalidOperationException: Cannot provide a value for property 'Http' on type 'MatBlazor.MatTable`1[[BlazorMaterialDesign.Data.WeatherForecast, BlazorMaterialDesign, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null]]'. There is no registered service of type 'System.Net.Http.HttpClient'.

Created on 16 Jun 2019  路  4Comments  路  Source: SamProf/MatBlazor

Annotation 2019-06-16 201939

I am using .net core 3.0 preview 6 and matblazor latest version and getting lot of issues

My Code:

`@page "/fetchdata"
@using BlazorMaterialDesign.Data
@inject WeatherForecastService ForecastService

<h1>Weather forecast</h1>

<p>This component demonstrates fetching data from a service.</p>

@if (forecasts == null)
{
    <p><em>Loading...</em></p>
}
else
{
    <MatTable Items="@forecasts"
                    LoadInitialData="true"
                    Striped="true"
                    FilterByColumnName="Date">
        <MatTableHeader>
            <th>Date</th>
            <th>TemperatureC</th>
            <th>TemperatureF</th>
            <th>Summary</th>
        </MatTableHeader>
        <MatTableRow>
            <td>@context.Date</td>
            <td>@context.TemperatureC</td>
            <td>@context.TemperatureF</td>
            <td>@context.Summary</td>
        </MatTableRow>
    </MatTable>
}

@code {
    WeatherForecast[] forecasts;

    protected override async Task OnInitAsync()
    {
        forecasts = await ForecastService.GetForecastAsync(DateTime.Now);
    }
}

`

Most helpful comment

You Should Register httpClient as Scoped :

services.AddScoped<HttpClient>();

All 4 comments

you need register HttpClient in services

Register HttpClient in services doesn't help.
@SamProf can you explain what exactly the solution is?

I'm also having this problem, isn't it HttpClientFactory in the latest version?

You Should Register httpClient as Scoped :

services.AddScoped<HttpClient>();

Was this page helpful?
0 / 5 - 0 ratings

Related issues

daviderusso1984 picture daviderusso1984  路  6Comments

vignatov picture vignatov  路  4Comments

JeroMiya picture JeroMiya  路  6Comments

rogeralsing picture rogeralsing  路  5Comments

kristof12345 picture kristof12345  路  5Comments