控制器无需控制器后缀 [英] Controller without the controller suffix

查看:169
本文介绍了控制器无需控制器后缀的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

根据我的设计要求,我会想从我的控制器排除后缀控制器和资源代替它。所以这是FundsController'将成为'FundsResource。

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?

先谢谢了。

推荐答案

控制器是硬codeD插入框架,但你可以你可以创建一个新的控制器类型解析。下面是从菲利普一篇优秀的文章 - 的http://www.strathweb.com/2013/02/but-i-dont-want-to-call-web-api-controllers-controller/.

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

这篇关于控制器无需控制器后缀的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆