Controller without the controller suffix

2019-02-25 05:13发布

based on my design requirements, I will like to exclude the suffix 'Controller' from my controllers and replace it with 'Resource'. So that 'FundsController' will become 'FundsResource'.

The problem is that I am not able to route to my specified actions by either convention based or attribute routing when I change replace the term 'Controller' and get an error saying that the controller with this name could not be found.

How can I satisfy the above mentioned design requirement and also be able to route without a problem? Either in Convention based or Attribute routing? Or whether if we can merge the benefits of convention based and attribute routing to achieve this?

Thanks in advance.

1条回答
再贱就再见
2楼-- · 2019-02-25 05:25

"Controller" is hard-coded into the framework but you can you can create a new controller type resolver. Here is an excellent article from Filip - http://www.strathweb.com/2013/02/but-i-dont-want-to-call-web-api-controllers-controller/.

查看更多
登录 后发表回答