Closed stevieTheCoder closed 3 years ago
As an interim work around registering IToastService as a singleton resolves the issue. Is there another solution?
Hi @stevieTheCoder, I'll have to investigate this one. I'm not sure why changing the IToastService
registration to a singleton has fixed the issue. Usually, this points to the IToastService
being injected into a service with a longer lifetime than its own. However, all your code appears to have a scoped lifetime, which is the same as the IToastService
.
Hi Chris I believe this is the reason why. https://www.google.com/amp/s/andrewlock.net/understanding-scopes-with-ihttpclientfactory-message-handlers/amp/ Unfortunately I don't think you can use the httpcontextaccessor in blazor wasm to resolve the dependencies as described.
Thanks for the info @stevieTheCoder. This seems a general oddity of ASP.NET Core and not an issue with this library. I don't think there is anything I can do, so I'm going to close this issue.
Describe the bug Toast is not displayed when called from an HttpMessageHandler.
To Reproduce Register a Scoped handler implementing DelegatingHandler, inject IToastService into the handler. Call toast.ShowError from the handler.
Expected behavior Toast message is displayed
Hosting Model (is this issue happening with a certain hosting model?):
Additional context
Api Handler class