很抱歉这个愚蠢的问题,但我怎样才能实现以下内容?
我有一个名为ServerMonitor的控制器,它只有一个Action
public ActionResult Index()
{
return Content(WebUtility.ServerID);
}
如何执行以下操作输入
http://mydom.com/ServerMonitor代替 http://mydom.com/ServerMonitor/Index
答案 0 :(得分:2)
您需要将路线网址中的{action}
参数默认设为"index"
ASP.Net MVC模板中定义的标准路由已经这样做了。
答案 1 :(得分:0)
routes.MapRoute
(
"RouteName",
{controller}",
new{action = "index", id = "UrlParameter.optional"
);
我认为这基本上就是你所需要的。