IHttpContextAccessor currently doesn't work
Dreamwalker666 opened this issue · comments
Dreamwalker666 commented
I discovered that I couldn't access the HttpContext in a DI based way. Not sure if this support was excluded for some reason (or I've completely gone about it the wrong way :)
I added the following before https://github.com/CarterCommunity/Carter/blob/master/src/Carter/CarterExtensions.cs#L86
// Setup HttpContext if services has been added with AddHttpContextAccessor
var httpContext = (IHttpContextAccessor)ctx.RequestServices.GetService(typeof(IHttpContextAccessor));
if (httpContext != null)
{
httpContext.HttpContext = ctx;
}
This solves my particular issue but would this be wanted in the main repo? If so I'll make a PR