Model view controller 忽略带有特定参数的路由

Model view controller 忽略带有特定参数的路由,model-view-controller,parameters,null,routes,Model View Controller,Parameters,Null,Routes,我有一个@url.Action,其中我将一个参数传递给该操作 当参数为null时,我只想什么都不做,保持在同一页上 我所做的工作如下: routes.MapRoute( null, "Test/View/{Id}", new { controller = "Test", action = "View" }, new { Id = @"\d+" } //id must be num

我有一个@url.Action,其中我将一个参数传递给该操作

当参数为null时,我只想什么都不做,保持在同一页上

我所做的工作如下:

routes.MapRoute(
           null,               
           "Test/View/{Id}",
           new { controller = "Test", action = "View" },
           new { Id = @"\d+" } //id must be numerical
           );
routes.IgnoreRoute("Test/View/{*pathInfo}");
操作未执行,但我的问题是我得到了以下结果:

Description: HTTP 404. The resource you are looking for (or one of its dependencies) could have been removed, had its name changed, or is temporarily unavailable.  Please review the following URL and make sure that it is spelled correctly.

Requested URL: /Test/View
我显然不想看到


感谢您的帮助。

为什么不在视图中使用一个条件,如果为true,则不会将文本呈现为链接,这样用户就无法单击它

或者,如果你绝对想让它成为一个链接,但想让用户保持在同一个页面上,那么就用老式的方式创建一个链接,使用锚标记并将其指向“#”。这样,它将呈现为链接,但当用户单击它时,它将不起任何作用