1

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.

WhileTrueSleep
  • 1,524
  • 1
  • 19
  • 32
Srikar
  • 31
  • 3

1 Answers1

0

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.

thepirat000
  • 12,362
  • 4
  • 46
  • 72
  • Newtonsoft.Json.JsonSerializationException occurred Message: Exception thrown: 'Newtonsoft.Json.JsonSerializationException' in Newtonsoft.Json.dll Additional information: Self referencing loop detected for property 'ApplicationInstance' with type 'ASP.global_asax'. Path 'Action.ActionParameters.request.Properties.MS_HttpContext.ApplicationInstance.Context'. – Srikar May 17 '17 at 06:43
  • My webapi is running on local system and i have used audit's sqldataprovider to log audit entries. – Srikar May 22 '17 at 09:46
  • Feel free to open a new issue https://github.com/thepirat000/Audit.NET/issues/new so you can provide more details on how to reproduce it. – thepirat000 Jun 10 '17 at 17:15