问题描述
我有一个名为控制器 InstallationController
,以及安装看上报告重新presentation称的价目表的,但最终的用户坚持调用安装自己的价目表的。我想他看到URL ,在此获得实际路由为 HTTP://网站/安装/编辑/ 3 。我怎样才能做到这一点MVC 3 RC2?
I have a controller called InstallationController
, and a fancy report representation of an installation called a Rate Card, but the end user insists on calling installations themselves Rate Cards. I would like him to see the URL http://site/RateCard/Edit/3, where this gets routed actually as http://site/Installation/Edit/3. How can I do this in MVC 3 RC2?
推荐答案
一对夫妇的选项,您可以重命名控制器 RateCardController
,或添加新的路由一个指向安装控制器,如:
A couple of options are, you can either rename the controller to RateCardController
, or add a new route that directs to the Installation controller, like:
routes.MapRoute(
"RateCard", // Route name
"RateCard/{action}/{id}", // URL with parameters
new { controller = "Installation", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);
这篇关于使用MVC路由别名控制器的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!