Adding Web API and API documentation to an existing MVC project

后端 未结 7 925
时光说笑
时光说笑 2021-02-14 03:01

I have successfully added a web api controller to an existing MVC4 application.

I would like to have the api documentation functionality as is

7条回答
  •  陌清茗
    陌清茗 (楼主)
    2021-02-14 03:41

    I just ran into this issue. Here's what it was for me.

    I'd had the Help pages working on a previous project (w/ MVC 5 and Web API 2) so I knew it was something different in my new project. Turned out in the old (working) project I was only doing DI in the WebApi controllers, not the MVC controllers. I didn't need DI in the MVC controllers, so I simply commented out the code bootstrapping the UnityDependencyResolver as the MVC dependency resolver (in my case the UnityMvcActivator class).

    Obviously this won't be an option for everyone, but where not, @Adrian Brown's answer looks like your best bet until this is fixed.

提交回复
热议问题