You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
When using the CorrelationIdEnricher and targeting .NET framework, a NullReferenceException will occur here: var header = httpContext.Request.Headers[_headerKey].ToString();
Because httpContext.Request.Headers[_headerKey] is actually null. The next line is:
This code works fine in .NET Core and unfortunately, there is no way that I can implement unit tests for enrichers when the target framework is .NET Framework and the reason is that HttpCaontext.Current is a static class and mocking it is extremely hard. For the next release, I will drop support for .NET Framework.
When using the
CorrelationIdEnricher
and targeting .NET framework, aNullReferenceException
will occur here:var header = httpContext.Request.Headers[_headerKey].ToString();
Because
httpContext.Request.Headers[_headerKey]
is actuallynull
. The next line is:This is a bit strange. You should call
.ToString()
after the null check, don't you?The text was updated successfully, but these errors were encountered: