Hi, thanks for the hard work. It is just a note.
Table component injects Http Client. However, on blazor server-side, it doesn't exist. you may want to add in the installation steps, adding something like:
services.AddScoped<HttpClient>();
OR
services.AddScoped<HttpClient>(s =>
{
var uriHelper = s.GetRequiredService<IUriHelper>();
return new HttpClient
{
BaseAddress = new Uri(uriHelper.GetBaseUri())
};
});
Yes, sure.
Also like I sad before MatTable will have big rewriting. So, in future this problem should be resolved.
Stumble upon the same problem. Rather then require an inject through services.AddScoped I would recommend changing the component itself to support situations where http is not available. To allow this the following code adaptation should work:
Change BaseMatComponent to use _OwningComponentBase_ instead of ComponentBase (or similar to cover MatTable only and not "every" component)
public abstract class BaseMatComponent : OwningComponentBase, IBaseMatComponent, IDisposable
Add to MatTable
@using Microsoft.Extensions.DependencyInjection
private System.Net.Http.HttpClient Http { get; set; }
protected override async Task OnInitializedAsync()
{
Http = ScopedServices.GetService<System.Net.Http.HttpClient>();
…
Remove from MatTable
@inject System.Net.Http.HttpClient Http
Also the functions SearchData and SearchPagedData have to be adapated to reflect that http might be NULL.
Most helpful comment
Stumble upon the same problem. Rather then require an inject through services.AddScoped I would recommend changing the component itself to support situations where http is not available. To allow this the following code adaptation should work:
Change
BaseMatComponentto use _OwningComponentBase_ instead of ComponentBase (or similar to coverMatTableonly and not "every" component)public abstract class BaseMatComponent : OwningComponentBase, IBaseMatComponent, IDisposableAdd to
MatTable@using Microsoft.Extensions.DependencyInjectionprivate System.Net.Http.HttpClient Http { get; set; }Remove from
MatTable@injectSystem.Net.Http.HttpClient HttpAlso the functions
SearchDataandSearchPagedDatahave to be adapated to reflect that http might be NULL.