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
Multiple times the event is called #7
Comments
@hsvasan Could you attach all files of a sample project which can reproduce that issue as a single zip package to this thread? |
I was seeing the same thing on BeforeSendAsync. The issue was I injected a custom http interceptor at the component level. So, it was registering an event listener for every component on the page that had this injected. Then each registered instance of the interceptor would fire once for every HTTP request in total on the page. @jsakamoto This may be what @hsvasan was also doing. I solved it by registering the http interceptor once in the App.razor component.
Custom interceptor:
|
@scottkuhl Thank you for providing important information and feedback! |
@jsakamoto I was speaking with another developer, and this did not solve the issue for them because they had multiple components on the page making HTTP requests. That does not mean there is anything wrong with HttpClientInterceptor, this is just more of an FYI if you want to investigate extending the code base to support this scenario more easily by optionally only firing once per page request. |
@scottkuhl Ok, I got it. Again, thank you for your kindness and for providing such helpful information. 👍 |
@drajatisme I don't have the exact code on how he did it, but he created a boolean variable per page request that flipped on the first hit and then would not fire on subsequent hits by checking the state of the flag. |
Uh... hi there, are you using this library on Blazor Server app, not on Blazor WebAssembly apps? That is why the event is called multiple times on Blazor Server apps, isn't it? Now, I'm considering changing the lifetimes of the services from "singleton" to "scoped" to support Blazor Server app scenarios. |
I am using the BlazorServer side project. i have created a HttpInterfaceService and created the AfterSendAsync and also removed the same in the disposeevent.
This is working fine, but it is called more than 5 times for every exception is being called.
Advise any settings to be done by me or is it an existing bug in the package.
The text was updated successfully, but these errors were encountered: