MVC 3更改/注册/事件/ 1?name = channel-news-asia to / Register / Event?name = channel-news-asia

时间:2012-04-12 16:32:18

标签: asp.net-mvc hyperlink

目前,我有http://localhost:xxxxx/Register,显示从数据库中检索的表格。

eName eLink fWidth fHeight
channel-new-asia http://www.channelnewsasia.com/ 1024 768 注册

现在,注册链接就像http://localhost:xxxxx/Register/Event/1?name=channel-news-asia,我该怎样做http://localhost:xxxxx/Register/Event?name=channel-news-asia

1 个答案:

答案 0 :(得分:1)

默认情况下,MVC使用此路由:

routes.MapRoute(
            "Default", // Route name
            "{controller}/{action}/{id}", // URL with parameters
            new { controller = "Home", action = "Index", id = UrlParameter.Optional } //Parameter defaults
        );

将名称为“id”的参数放入页面上的请求somwhere。因此,URL包含'id'参数。您需要使用其他名称(不是'id'),或者您应该更改默认名称。