endpoints.MapControllers();

来源:2-4 【应用】添加第一个API

weixin_宝慕林6551387

2021-09-12

endpoints.MapControllers();
然后报错
System.InvalidOperationException:“Unable to find the required services. Please add all the required services by calling ‘IServiceCollection.AddControllers’ inside the call to ‘ConfigureServices(…)’ in the application startup code.”

咋回事啊

写回答

1回答

阿莱克斯刘

2021-09-15

hello 同学你好,请检查一下startup.cs文件中有没有添加 AddControllers 服务依赖呢?

代码如下

void ConfigureServices(IServiceCollection services) {    
    //...
    services.AddControllers();    
    //...
}



0
0

.Net 开发电商后端API 从0到精通RESTful

. Net 实战+RESTful思想纵深课程,开发优雅RESTful风格API。

978 学习 · 547 问题

查看课程