audit.net

How to use GetCurrentAuditScope metthod in an ActionFilterAttribute


How to uses the GetCurrentAuditScope() (or another) method in an ActionFilterAtribbute on MVC and WebAPI to get the AuditScope.

I need recover that on OnActionExecuted(HttpActionExecutedContext actionExecutedContext) event.

Or have another thing which i can uses?


Solution

  • Yes, you can use the GetCurrentAuditScope() Extension Method on HttpContext, for example:

    using Audit.WebApi;
    // ...
    
    public override void OnActionExecuted(ActionExecutedContext context)
    {
        var scope = context.HttpContext.GetCurrentAuditScope();
        // ...
    }