Base controller from another class library doesn't working in web api

后端 未结 2 1689
暗喜
暗喜 2021-01-22 11:43

I have two Web API projects and I have a MarketController and I need to extend the Api controller so I did it.

I created a BaseController class

2条回答
  •  隐瞒了意图╮
    2021-01-22 11:59

    No need to implement custom ControllerFactory or AssemblyResolver classes. This scenario will "just work" provided you add the Microsoft.AspNet.WebApi.Core nuget package to the assembly containing the base class.

    In my case I'd just added a reference to the System.Web.Http.dll which will compile, but the controllers will not load properly. Adding the Nuget package got everything working with no code changes.

提交回复
热议问题