我是MVC的新手,并且有一个我正在努力的应用程序.我有2个不同的链接,在我的全球范围内有2条路线,这些路线相当类似
路线1
routes.MapRoute("Category", "Movies/{category}/{subcategory}", new { controller = "Catalog", action = "Index", category = "", subcategory = "" });
路线2
routes.MapRoute("Movie", "Movie/{movie}", new { controller = "Movie", action = "Index", movie = "" });
当我为第一条路线调用一个动作链接时,它会创建它,因为我认为它应该:
.../Movies/Category/SubCategory
但是,当我创建我的第二个链接时,它填充它像这样:
.../Movie?movieId=ff569575-08ec-4049-93e2-901e7b0cb96a
之前我使用的是字符串而不是guid,它仍然在做同样的事情
.../Movie?movieName=Snatch
我的actionlinks设置如下
<%= Html.ActionLink(parent.Name, "Index", "Catalog", new { category = parent.Name, subCategory = "" }, null)%> <%= Html.ActionLink(movie.Name, "Index", "Movie", new { movieId = movie.MovieId }, null)%>
我的应用程序仍然有效,但我认为这种行为很奇怪.任何帮助都会很棒.
谢谢!
routes.MapRoute("Movie", "Movie/{movieId}", new { controller = "Movie", action = "Index", movie = "" });
路由文本是否应与您提交给mvc链接的属性的名称不匹配?