-
Notifications
You must be signed in to change notification settings - Fork 10.4k
Description
Blazor supports the notion of events, such as @onlick
events, as shown here:
<button class="btn btn-danger" @onclick="DeleteUser">Delete</button>
This allows the DeleteUser
method to be invoked in the page's @code
section.
I'm looking for a mechanism that allows intercepting calls those 'code behind' methods, in order to be able to execute some infrastructure logic right before the method is invoked. If such mechanism is currently missing, I would urge the addition of a feature that makes this possible.
This question/discussion is related to my earlier issues #19642 and #29194 because I'm trying to find ways to integrate non-conforming DI Containers (such as Simple Injector) with the Blazor pipeline. As non-conforming containers don't replace the built-in DI Container, but merely live side-by-side, it is important to be able to start or continue a non-conforming container's Scope at the proper time.
Starting and continuing an existing scope can be done partially by:
- intercepting the creation of Blazor components (using
IComponentActivator
) to start/continue a scope - intercepting the creation of SignalR hubs (using
IHubActivator<T>
) to start/continue a scope
This unfortunately leaves us with the invocation of Blazor events. When they are invoked, neither the IComponentActivator
nor IHubActivator<T>
is called, which causes that code to be executed outside the context of a non-conforming container's scope.
I might have overlooked the proper interception point for this in the Blazor code base. If there is such an interception point, please let me know. If there isn't, I would like to see it added.