我有一个ASP.Net MVC4应用程序,正在使用Url.Action助手,如下所示:@Url.Action("Information", "Admin")
此页用于添加新的管理员配置文件和编辑管理员配置文件。URL如下:
Adding a new: http://localhost:4935/Admin/Information
Editing Existing: http://localhost:4935/Admin/Information/5 <==Admin ID当我在站点的Editing Existing部分,决定添加一个新的管理员时,我点击下面的链接:
<a href="@Url.Action("Information", "Admin")">Add an Admin</a>然而,问题是上面的链接实际上是指向http://localhost:4935/Admin/Information/5的。只有当我在该页面中编辑现有管理员时才会发生这种情况。在站点上的任何其他地方,它都可以正确地链接到http://localhost:4935/Admin/Information
还有人看过这个吗?
更新:
RouteConfig:
routes.MapRoute(
name: "Default",
url: "{controller}/{action}/{id}",
defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }
); https://stackoverflow.com/questions/19107061
复制相似问题