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

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

Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting_第1张图片

解决方案:

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

services.AddHttpContextAccessor();

Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor' while attempting_第2张图片

你可能感兴趣的:(dotNet)