Audit.WebAPI configuration

736 Views Asked by At

I am using version 7.0.6 of Audit.NET. I added the following line to my WEB API registration method

config.Filters.Add(new Audit.WebApi.AuditApiAttribute());

When i run the application it gives the following runtime error

self referencing loop detected with type Appinstance.Path 'Action.ActionParameters.request.Properties.MS_HttpContext.ApplicationInstance.Context'.

I am using latest version of Newtonsoft.JSON from Nuget.

1

There are 1 best solutions below

3
On

Can you provide the stack trace?

That error means Newtonsoft.Json was unable to serialize an object that has a reference loop, but the json conversion used by default on Audit.NET already handles this, by ignoring the reference loops with ReferenceLoopHandling setting set to Ignore.

https://github.com/thepirat000/Audit.NET/blob/master/src/Audit.NET/AuditEvent.cs#L73

Are you using a custom data provider to save the events?

If so, please be sure to use the provided AuditEvent ToJson method, or any other method that handles self references.