如何将MVC路由添加到特定控制器? [英] How do I add a MVC route to a specific controller?
本文介绍了如何将MVC路由添加到特定控制器?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我的头脑有些空白.我该怎么做:
My mind is somehow blank. How do I do this:
我有一个RegistrationController
,并希望URL /register
在该控制器上执行操作Register
.在global.asax中,我必须添加什么作为地图路线?
I have a RegistrationController
and want the URL /register
to hit the action Register
on that controller. What do I have to add as a map route in global.asax?
推荐答案
实际上,您想要的是这样的
Actually, what you want is this:
routes.MapRoute(
"RegisterRoute",
"Register",
new { controller = "Registration", action = "Register" }
);
现在,您可以使用以下网址访问页面:
Now you can go to your page with an url like:
http://www.yoursite.com/register
这篇关于如何将MVC路由添加到特定控制器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文