Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting

在使用asp.net core时,碰见这个错误

解决方案:

在startup.cs文件中配置服务:

services.AddHttpContextAccessor();

原文地址:https://www.cnblogs.com/AlexanderZhao/p/12878896.html