特定の「テーマ」でタグ付けされたパズルのリストがあります。特定のカテゴリでタグ付けされたスタックオーバーフローで質問を考えてください。
次のように機能するように、ルート設定を取得しようとしています。
http://www.wikipediamaze.com/puzzles/themed/Movies http://www.wikipediamaze.com/puzzles/themed/Movies,Another-Theme,And-Yet-Another-One
私のルートは次のように設定されています:
routes.MapRoute(
"wiki",
"wiki/{topic}",
new {controller = "game", action = "continue", topic = ""}
);
routes.MapRoute(
"UserDisplay",
"{controller}/{id}/{userName}",
new {controller = "users", action = "display", userName=""},
new { id = @"\d+" }
);
routes.MapRoute(
"ThemedPuzzles",
"puzzles/themed/{themes}",
new { controller = "puzzles", action = "ThemedPuzzles", themes = "" }
);
routes.MapRoute(
"Default", // Route name
"{controller}/{action}/{id}", // URL with parameters
new {controller = "Home", action = "Index", id = ""} // Parameter defaults
);
私のコントローラーは次のようになります。
public ActionResult ThemedPuzzles(string themes, PuzzleSortType? sortType, int? page, int? pageSize)
{
//Logic goes here
}
ビューでのアクション リンクの呼び出しは次のようになります。
<ul>
<%foreach (var theme in Model.Themes)
{ %>
<li><%=Html.ActionLink(theme, "themed", new {controller = "puzzles", themes = theme})%></li>
<% } %>
</ul>
しかし、私が抱えている問題はこれです:
生成されるリンクは次のように表示されます。
http://www.wikipediamaze.com/puzzles/themed?themes=MyThemeNameHere
この問題に加えて、コントローラー アクションの "Themes" パラメーターは常に null になります。クエリ文字列パラメーターをコントローラー アクション パラメーターに変換することはありません。ただし、手動で移動すると
http://www.wikipediamaze.com/puzzles/themed/MyThemeNameHere http://www.wikipediamaze.com/puzzles/themed/MyThemeNameHere,Another-ThemeName
すべてがうまく機能します。私は何が欠けていますか?
前もって感謝します!