Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting 在使用asp.net core时,碰见这个错误 解决方案: 在startup.cs文件中配置服务: services.AddHttpContextAccessor();