You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
We are writing a new application using signalR to perform updates and disperse updates on all of the business objects in our application. We were hoping to that like Mvc Controllers we could hook into before and after a method is invoked (i.e. OnActionExecuting() and OnActionExecuted()). However, there seems to be no way to do this in signalR.
Our use case for this is varied. The biggest 2 that come to mind are:
Setting custom properties in a logging (or other) context. For example, the adding parameter values that were used to invoke the method.
Audit logging. Are application has requirements for audit logging. We have implemented this in an "old school" way before by having a centralized class/method that can be injected/invoked.
Being able to hook into these two events would give us the advantage that the developer does not need to remember to call a central method every time an action is taken. This is something that we have had issues with before.
Ideally, 2 (or 3, if you want to support async) methods would be added to the base Hub class. The default implementation would do nothing, but they could be overridden to perform what we need:
OnActionExecuting(HubActionContext ctx) - invoked before a Hub method is invoked by the client.
OnActionExecuted(HubActionContext ctx) - invoked after a Hub method is invoked by the client.
OnActionExecutionAsync((HubActionContext ctx, ActionDelegate delegate) - invoked before the hub method is called. delegate that is called to continue execution.
HubActionContext would be similar to the current HubCallerContext with the following additional values:
Action - the Method for the action that is being invoked.
ActionArguments - the parameters for the action being invoked (similar to ActionExecutingContext.ActionArguments in the Microsoft.AspNetCore.Mvc.Filters namespace.
The text was updated successfully, but these errors were encountered:
We are writing a new application using signalR to perform updates and disperse updates on all of the business objects in our application. We were hoping to that like Mvc Controllers we could hook into before and after a method is invoked (i.e.
OnActionExecuting()
andOnActionExecuted()
). However, there seems to be no way to do this in signalR.Our use case for this is varied. The biggest 2 that come to mind are:
Being able to hook into these two events would give us the advantage that the developer does not need to remember to call a central method every time an action is taken. This is something that we have had issues with before.
Ideally, 2 (or 3, if you want to support async) methods would be added to the base
Hub
class. The default implementation would do nothing, but they could be overridden to perform what we need:OnActionExecuting(HubActionContext ctx)
- invoked before a Hub method is invoked by the client.OnActionExecuted(HubActionContext ctx)
- invoked after a Hub method is invoked by the client.OnActionExecutionAsync((HubActionContext ctx, ActionDelegate delegate)
- invoked before the hub method is called.delegate
that is called to continue execution.HubActionContext
would be similar to the currentHubCallerContext
with the following additional values:Action
- theMethod
for the action that is being invoked.ActionArguments
- the parameters for the action being invoked (similar toActionExecutingContext.ActionArguments
in theMicrosoft.AspNetCore.Mvc.Filters
namespace.The text was updated successfully, but these errors were encountered: