-
Notifications
You must be signed in to change notification settings - Fork 10.3k
Document how to configure HttpClient base address in Blazor Server using IHttpClientFactory #25758
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Comments
Tested it with both 3.1 and 5.0-preview8, same result. |
We've moved this issue to the Backlog milestone. This means that it is not going to be worked on for the coming release. We will reassess the backlog following the current release and consider this item at that time. To learn more about our issue management process and to have better expectation regarding different types of issues you can read our Triage Process. |
Thanks for contacting us. |
Is there a workaround, or other solution meanwhile that can be promoted whilst it is in process of enhancement @SteveSandersonMS / @mkArtakMSFT? Thanks! |
I would just simply use the default http client factory I did this kind of overriding the base http client address and it was a bad idea once when I started with blazor wasm and server. I falled back to just include the What happens if you want to get a resource which is on the You will lose this main address in your http client... If you are on native application then this would make sense at all to do it. I would suggest to change approach and make a HttpClientService per specific API controllers instead and inside set up you base http client address. I know this doesn't answer the asked question but it's my experience based on this when I did this approach before this should not be done at all. I even think it should be considered a bad practice at all. |
I would also like to see this addressed. I need to be able to add a user's access token to a named HTTP client. But I'm getting the same exception when I try to resolve the AuthenticationStateProvider to figure who the user is. This should be a supported scenario. |
Thanks for contacting us. |
When fixing this, verify that it also fixes #40336 |
I am trying to configure
HttpClient
's base address in a Blazor Server usingIHttpClientFactory
but I am getting a runtime exception:Create an instance of this HttpClient using IHttpClientFactory and the following exception will be thrown:
_httpClient = httpClientFactory.CreateClient("ApiClient");
System.InvalidOperationException: 'Cannot resolve scoped service 'Microsoft.AspNetCore.Components.NavigationManager' from root provider.'
Anyone knows what might be the issue here?
The text was updated successfully, but these errors were encountered: