I use the following code to register httpcontextbase, but sometimes there are non null errors.
error message:
Value cannot be null. Parameter name: httpContext