Once in a while, we are observing this error in an ASP.NET Web API service module in a live environment and the issue gets resolved after application pool recycling. This error happened while sending the response and once the error starts happening, all the subsequent requests are failing with the same error. We couldn't reproduce this error in lower environments though. And the error occurred even with a simple GET method.
"stacktrace": " at Sy stem.Net.Http.Formatting.BaseJsonMediaTypeFormatter.CreateJsonSerializerInternal()\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.JsonMediaTypeFormatter.WriteToStream(Type type, Object value, Stream writeStream, Encoding effectiveEncoding)\r\n at System.Net.Http.Formatting.BaseJsonMediaTypeFormatter.WriteToStreamAsync(Type type, Object value, Stream writeStream, HttpContent content, TransportContext transportContext, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)\r\n at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n at System.Web.Http.WebHost.HttpControllerHandler.d__1b.MoveNext()", "exception_class": "System.InvalidOperationException",
"exception_message": "The 'CreateJsonSerializer' method threw an exception when attempting to create a JSON serializer.
"
If anyone has come across this error, please share your thoughts.