2012-11-25 47 views
0

对不起,这个愚蠢的问题,但我怎么能实现以下事情?MVC 3导航到控制器

我有一个名为ServerMonitor控制器,它只有一个动作

public ActionResult Index() 
     { 
      return Content(WebUtility.ServerID); 
     } 

我如何可以执行以下操作键入

http://mydom.com/ServerMonitor,而不是http://mydom.com/ServerMonitor/Index

回答

2

您需要使路由URL中的{action}参数默认为"index"
在ASP.Net MVC模板中定义的标准路由已经这样做了。

+0

非常感谢! – StringBuilder

0
routes.MapRoute 
(
"RouteName", 
{controller}", 
new{action = "index", id = "UrlParameter.optional" 
); 

我认为这基本上是你需要的。