question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Feature Request - add ActionExecutingContext parameters to Audit.WebApi

See original GitHub issue

Not sure if it’s possible, I didn’t find a way.

I have a use case where I would like to add some ActionExecutingContext data to the Audit event, it seems like the current interface doesn’t allow it.

Something like that can work:

options.AddAuditFilter(config => config.LogAllActions()
            .WithEventType("{verb}.{controller}.{action}")
            .IncludeExtraParameteras(actionExecutingContext => actionExecutingContext.HttpContext["customParameter"]);

What do you think?

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (3 by maintainers)

github_iconTop GitHub Comments

1reaction
ofir-shapira-comocommented, Nov 27, 2019

Thanks @thepirat000, it works well, please note that I am using it in AddOnSavingAction but I tested it in AddCustomAction as well:

Audit.Core.Configuration.AddOnSavingAction(scope =>
{
    var actionExecutingContext = scope.GetWebApiAuditAction()?.GetActionExecutingContext();
    if (actionExecutingContext != null)
    {
        scope.SetCustomField("User", actionExecutingContext.HttpContext.GetCurrentHubUser());
    }
});

You may close, thanks!

1reaction
thepirat000commented, Nov 26, 2019

This was added on version 14.8.1, please upgrade and re-test.

Read more comments on GitHub >

github_iconTop Results From Across the Web

How to get controller value in Action filter in Web API
How to get method name and Controller name in Action Filter and Exception Filter. public class ActionDetailAttribute : System.Web.
Read more >
Implementing Action Filters in ASP.NET Core
Find out how to use action filters to write cleaner actions and create a reusable code to validate your actions in .NET Core...
Read more >
Request Response Logging Middleware ASP.NET Core
Middleware. Here, in InvokeAsync() method, we are assigning values to the log model from HttpRequest and HttpResponse .
Read more >
How to Audit Your ASP.NET Core WebApi
Add to services​​ That's it! Run the api, make a http call and see the full audit log in standard output. Voilà !...
Read more >
Filters in ASP.NET Core
Filters that are implemented as attributes and added directly to controller classes or action methods cannot have constructor dependencies ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found