3

ルート :

   routes.MapRoute("Default", "{controller}/{action}/{id}/{args1}/{args2}/{args3}", // URL with parameters
              new
              {
                  controller = "Home",
                  action = "Index",
                  id = UrlParameter.Optional,
                  args1 = UrlParameter.Optional,
                  args2 = UrlParameter.Optional,
                  args3 = UrlParameter.Optional
              }
          );

以下のコードを使用してリンクを作成します。

 @Html.ActionLink("Photos", "List", "Photos");//"photos" is controller name and "list" is action name

その生成アンカーですが、url/link は空白です。

一部のアクションに追加のパラメーターが必要だったため、Route を変更しました。

私はMVCを初めて使用しています。解決策を教えてください。

4

1 に答える 1

3

デフォルト ルートがアクティブになっていないようです。アクティブになっている場合は、アクティブにします。

routes.MapRoute(
                "Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
            );
于 2011-12-05T07:31:36.767 に答える