1

I am using Audit.Net and Audit.MVC 14.2.2.0. Great framework!

I have extended the AuditDataProvider:

 public class SQLAuditDataProvider : AuditDataProvider

In that class, I would like to get hold of the auditEvent's Action object, so that I can log the Username. (I don't want the Environment's username, although I can get it.) When I debug, I can see that Action property, but when I try to type it, I get a compile time error.

I could store it as a CustomField in the HomeController, but it would be preferable simply to get it in the SQLAuditDataProvider.

I'm probably doing something stupid, but what have I missed?

Igavshne
  • 699
  • 7
  • 33

1 Answers1

1

You can cast the AuditEvent as AuditEventMvcAction and then access the Action property:

var action = (auditEvent as AuditEventMvcAction).Action;

Or you can use the convenient extension method:

using Audit.Mvc;

var action = auditEvent.GetMvcAuditAction();

// Or from the audit scope
var action = auditScope.GetMvcAuditAction();
thepirat000
  • 12,362
  • 4
  • 46
  • 72