How do I register a controller that has been created in an AREA

前端 未结 2 1244
面向向阳花
面向向阳花 2020-12-07 05:43

I am using MVC4\'s WEB API to expose a controller.

Initially I created created a MVC4 WEBAPI project, set the project not to open any web page, wait for an external

2条回答
  •  情话喂你
    2020-12-07 06:22

    While it is possible to place WebApi Controllers in different Areas, ASP.NET MVC 4 RC will still treat these ApiControllers as if they all reside in the same namespace. This is a limitation of the DefaultHttpControllerSelector, which is responsible for selecting the appropriate ApiController.

    Fortunately, you can inject your own implementation of this class. In fact, I've already encountered this very issue and written an "area aware" HttpControllerSelector. You can find a blog post of mine about this issue and its solution here:

    http://blogs.infosupport.com/asp-net-mvc-4-rc-getting-webapi-and-areas-to-play-nicely/

提交回复
热议问题