Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor'
An unhandled exception occurred while processing the request.
Microsoft.Extensions.DependencyInjection.ServiceLookup.CallSiteFactory.CreateArgumentCallSites(Type serviceType, Type implementationType, CallSiteChain callSiteChain, ParameterInfo[] parameters, bool throwIfCallSiteNotFound)
As of .NET Core 2.1 there is an extension method that has been added to correctly register an IHttpContextAccessor as a singleton. See Add helper to register IHttpContextAccessor #947. Simply add as follows in your ConfigureServices() method:
services.AddHttpContextAccessor();
Unable to resolve service for type 'Microsoft.AspNetCore.Http.IHttpContextAccessor'的更多相关文章
- InvalidOperationException: Unable to resolve service for type 'Microsoft.AspNetCore.Identity.UserManager`1[Microsoft.AspNetCore.Identity.IdentityUser]'
在新建asp.net core 应用后, 添加了自定义的ApplicationDbContext 和ApplicationUser ,并添加了Identity认证后, 会出现 InvalidOpera ...
- Unable to resolve service for type 'Microsoft.AspNetCore.ResponseCompression.IResponseCompressionProvider' while attempting to activate 'Microsoft.AspNetCore.ResponseCompression.ResponseCompressionMid
System.InvalidOperationException HResult=0x80131509 Message=Unable to resolve service for type 'Micr ...
- Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activate 'xxxxx.Controllers.xxxxController'.
Unable to resolve service for type 'Microsoft.Extensions.Logging.ILogger' while attempting to activa ...
- Core 3.1 MVC 抛异常“InvalidOperationException: No service for type 'Microsoft.AspNetCore.Mvc.ViewFeatures.ITempDataDictionaryFactory' has been registered.”
.NET Core 的版本是 3.1遇到的问题是 Action 中 return View() 的时候报错 An unhandled exception occurred while processi ...
- TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.Internal.IHttpResponseStreamWriterFactory' from assembly 'Microsoft.AspNetCore.Mvc.Core, Version=2.1.2.0 ...
今天调试 asp.net core 2.0 项目时遇到了如下错误: TypeLoadException: Could not load type 'Microsoft.AspNetCore.Mvc.I ...
- .net core 3.0web_razor page项目_使用中间件接受大文件上传报错_httpRequest.Form threw an exception of type Microsoft.AspNetCore.Server.Kestrel.Core.BadHttpRequestException_Request body too large
前言:在web项目的.net framework时文件上传时,自己常用一般处理程序接受上传文件,上传文件的大小限制是可以项目的webconfig里配置. 到core项目使用一般处理程序变成了中间件 ...
- Orchard Core 版本冲突 The type 'FormTagHelper' exists in both 'Microsoft.AspNetCore.Mvc.TagHelpers, Version=2.1.1.0, Culture=neutral, PublicKeyToken=adb9793829ddae60' and...
最近老大让我看Orchard Core,这是一个CMS系统.可以先参考大佬的文章:https://www.cnblogs.com/shanyou/archive/2018/09/25/9700422. ...
- Unable to resolve address ' ' service ' ': Name or service not known
感谢朋友支持本博客,欢迎共同探讨交流,因为能力和时间有限,错误之处在所难免.欢迎指正. 假设转载,请保留作者信息. 博客地址:http://blog.csdn.net/qq_21398167 原博文地 ...
- Unable to cast object of type 'System.Int32' to type 'System.String'.
最近在研究.netcore,尝试把前后端完全分离.但是在写接口的时候,Post参数是FromBody的时候报错了 Microsoft.AspNetCore.Diagnostics.DeveloperE ...
随机推荐
- IIS URL Rewriting and ASP.NET Routing
IIS URL Rewriting and ASP.NET Routing With the release of the URL Rewrite Module for IIS and the inc ...
- linux cheese摄像机工具在window电脑上显示
1.SSH Secure Shell Client 2.Xming 实现步骤: 1.运行Xming工具 2.运行SSH Secure Shell Client,登陆linux系统 输入命令:expor ...
- Hibernate 自动更新表出错 建表或添加列,提示标识符无效
如Oracle 数据库下报错: create table db_meta_web.user (id varchar2(255 char) not null, account varchar2(255 ...
- 阶段5 3.微服务项目【学成在线】_day18 用户授权_10-前端集成认证授权-需求分析
4 前端集成认证授权 4.1 需求分析 截至目前认证授权服务端的功能已基本完成,本章实现前端集成认证授权功能. 前端集成认证授权功能需要作如下工作: 1.前端页面校验用户的身份,如果用户没有登录则跳转 ...
- 怎样创建一个OpenStack官方账号?
OpenStack官方账号分两种: 社区成员 (Community Member) 基金会成员 (Foundation Member) 基金会成员比社区成员的权利多一点: 允许提交峰会议题 允许对峰会 ...
- 对Mysql数据表本身进行操作
创建实验环境 mysql> create database test_db; Query OK, 1 row affected (0.00 sec) mysql> use test_db; ...
- 123457123456#0#-----com.twoapp.ErTongHuaHua01--前拼后广--儿童绘画填色游戏jiemei
com.twoapp.ErTongHuaHua01----儿童绘画填色游戏jiemei
- Node.js event loop 和 JS 浏览器环境下的事件循环的区别
Node.js event loop 和 JS 浏览器环境下的事件循环的区别: 1.线程与进程: JS 是单线程执行的,指的是一个进程里只有一个主线程,那到底什么是线程?什么是进程? 进程是 CPU ...
- Python 解析式、生成器
标准库datetime datetime模块 对日期.时间.时间戳的处理 datetime类 类方法 today() 返回本地时区当前时间的datetime对象 now(tz=None) 返回当前时间 ...
- 【c# 学习笔记】析构函数
析构函数 用于在类销毁之前释放类实例所使用的托管和非托管资源.对应c#应用程序所创建的大多数对象,可以依靠.net Framework的垃圾回收站(GC) 来隐式地执行内存管理任务.但若创建封装了非托 ...