Closed
Description
After updating my Web API project from .NET Core 3.1 to .NET 5, I'm getting a warning along the lines of "variable is never null".
var contentType = httpContext.Request.ContentType;
if (contentType != null && contentType != allowedContentType)
{
// ^^^^^^^^^^^^^
}
The warning is incorrect, because when I remove the null check, lots of my integration tests start to fail. Specifically, the ones where no Content-Type header is sent in the request.
This makes me believe the HttpRequest.ContentType property type should be string?
instead of string
.