Routing in Web Api in ASP.NET MVC 4

前端 未结 2 432
感情败类
感情败类 2021-02-06 09:05

I am using web api with ASP.NET MVC 4.

I have the following named controller

  • CustomerController : Controller
  • CustomerApiController : ApiController
2条回答
  •  野性不改
    2021-02-06 09:26

    You could extend DefaultHttpControllerSelector and override GetControllerName to apply a custom rule. The default implementation just returns the value of the "controller" variable from the route data. A custom implementation could map this to some other value. See Routing and Action Selection.

提交回复
热议问题