Controller without the controller suffix

牧云@^-^@ 提交于 2019-12-20 02:38:07

问题


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:


"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/.



来源:https://stackoverflow.com/questions/22778330/controller-without-the-controller-suffix

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!