Closed carlosalcantara2668 closed 5 years ago
"does not work" isn't an appropriate error description. Any exceptions? What do you see that makes you think it doesn't work? Did you take care of step 2 of the howto? Be extra careful to register the HttpClient inside the Startup.cs of the Client Project: https://github.com/Suchiman/BlazorDualMode/blob/853b2ec3d4b3ac028c365d593265e932912f02ff/BlazorDualMode.Client/Startup.cs
if you register it, if you perform the exercise of creating a service to center http calls and change to the server model, it simply does not respond.
if the call is direct within the page if you are working very well in the server model.
Please try to make the call of the http on the FetchData page through a registered service.
Please forgive my writing in English. that I am new studying the language.
@carlosalcantara2668 i see, try using AddScoped
instead of AddSingleton
, that works for me.
The reason is that Blazors IUriHelper
is a Scoped
service hence HttpClient
must be scoped and so does ServiceArticulo
. The problem is that a singleton service (longer lifetime) cannot resolve a scoped service (shorter lifetime).
@Suchiman now it's working, this is perfect, thank you very much.
I did a service to centralize the http, but when changing from the client model to the server, it simply does not work.