Lost instance of my grpc in blazor webassembly when reload page

19 views Asked by At

I have one solution project SLN in .net so, I created the reference of grpc in my blazor project for instance this in my code. All the validation, auth/login work fine I can render data in my component when user login but whenn try to refresh the application lost the connection with grpc like if the channel closed. There“s my program.cs where I added the grpc like singleton for keep live in all the execution.

Programs.cs

        var builder = WebAssemblyHostBuilder.CreateDefault(args);
        builder.RootComponents.Add<App>("#app");
        builder.RootComponents.Add<HeadOutlet>("head::after");

        builder.Services.AddScoped(sp => new HttpClient { BaseAddress = new Uri(builder.HostEnvironment.BaseAddress) });

        ...
        builder.Services.AddSingleton<gRPCJamLogic>();
        builder.Services.AddSingleton<GrpcHandler>();
        ...


        await builder.Build().RunAsync();
    }
}

}

This is the output when reload the page

Output:

Error in http_wasm_abort_response: TypeError: network error
Error fetching data: Object reference not set to an instance of an object.

Is this a problem of blazor or I do a bad implementation?

0

There are 0 answers