Hi Team,
We are using web APIs in our project, The time we access first web API from our project we get a 500 error as a response. once we restart the app pool on the machine, the error goes away and everything works fine.
It occurs very rarely. So, it's very hard to reproduce. error is invoked on its own
As per our current investigation, we noted once in our local machine while debugging found the attached exception.
We get a null reference exception while serializing objects to JSON. check attachment for info
The issue occurs very rarely on both server(Windows Server 2019) and local window machine
.net framework version being used with this mvc c#.net webapi is 4.5.1
Following things we have tried : -
- Upgraded the json version to Newtonsoft.json.13.0.1
- Update the response to a mvc model from as earlier we were sending entity
- Globally we have setup the below line in webapiconfig file
config.Formatters.JsonFormatter.SerializerSettings.ReferenceLoopHandling = Newtonsoft.Json.ReferenceLoopHandling.Ignore;