不带控制器后缀的控制器 [英] Controller without the controller suffix

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

问题描述

根据我的设计要求,我想从我的控制器中排除后缀Controller"并将其替换为Resource".这样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?

提前致谢.

推荐答案

"Controller" 被硬编码到框架中,但您可以创建一个新的控制器类型解析器.这是 Filip 的一篇优秀文章 - 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天全站免登陆