Our Cookie Policy

Echofavor and carefully selected third parties use cookies on this site to improve performance, for analytics and to show you offers tailored to your interests on our site and third party sites. By continuing to use our site, you consent to our use of cookies. Privacy Policy

Life is memorable. Share your experience. Help others. Return the favor. Terms Of Use    Privacy Policy    About    FAQ    Help   Contact Us  
As an Amazon Associate and affiliate with other third parties, Echofavor earn from qualifying purchases and display advertisements.
0.1003966

(Collection)Blazor Issues

  • mcchu28
  • 183 views


@inject HttpClient Http does not work on Blazor server application

  • 204 views
The following code to  inject http service does not seem to work on a Blazor Server application.

@inject HttpClient Http

Even the default project from Visual Studio does not use HTTP injection. I am not sure if this is a change from the client side blazor, but I presume so.

Instead, they inject a custom service class:

@inject WeatherForecastService ForecastService

protected override async Task OnParametersSetAsync()
    {
        forecasts = await ForecastService.GetForecastAsync(StartDate);
    }


So the default project override the app method as follow.

    public class DefaultWeatherForecastService : WeatherForecastService
    {

        public override Task<WeatherForecast[]> GetForecastAsync(DateTime startDate)


So the above example just call the server code to retrieve data from a file.

An example of calling an API through server code can be found here:
Probably you won't be using custom class IHttpApiClientRequestBuilderFactory but rather the HttpClient class.

[New Update Sep. 14, 2018]
At the bottom of this github issue, you will find Dan Roth's answer that you can add HttpClient to the server project. I will have to try this.

[New Update Sep. 20, 2018]
@robertmclaws The HttpClient uses JS interop to call into the fetch API (BrowserHttpMessageHandler). We don't introduce a new cookie container.

I also found on this thread https://github.com/aspnet/Blazor/issues/1115:
It talks about leverage the API client generation work planned for ASP.NET Core 2.2 to enable strongly typed API calls.









Session state not working on server side Blazor

  • 311 views
I am trying to do some oauth claim authorization but realize subsequent request does not have User.Identity.IsAuthenticated set to true. In fact, other properties under ControllerBase.Request, Context, User are all null.

The issue has to do with session not support through signalR on blazor at the moment. It has been deferred till ASP.NET Core 3.





  

Copyright © Echofavor 2021. All Rights Reserved. Powered by Echofavor
Copyright © Echofavor 2021. All Rights Reserved.
Powered by Echofavor