我搜索并阅读了所有在这里和谷歌上能找到的问题,但似乎找不到答案!
这个问题中的路由器是这样的:
routes.MapRoute("Admin - Change Password", "Admin/ResetPassword/{UserId}", New With {.controller = "Admin", .action = "ResetPassword", .UserId = ""})
生成的URL是: /Admin/UserAdmin
这是url.action所在的页面。不知道这是否重要。
当我使用路由调试器时,它显示了我希望生成的URL与我在地址栏中键入的URL相匹配。
真正的 Admin/ResetPassword/{UserId} 控制器=Admin,操作=ResetPassword,userId=
它匹配的唯一其他路由是:
True {controller}/{action}/{id} controller=Home,action=Index,id=
True {*catchall} (null)
{controller}/{action}/{id}路由是最后一个,因此不应干扰。
有任何想法吗?
编辑:助手的代码:
<%Url.Action("ResetPassword", "Admin", new with {.UserId= u.userId}) %>