次のように定義されたアクションがあります。
public ActionResult Foo(int[] bar) { ... }
次のような URL は期待どおりに機能します。
.../Controller/Foo?bar=1&bar=3&bar=5
いくつかの作業を行い、Foo
計算された の値について上記のアクションにリダイレクトする別のアクションがありますbar
。
上記の例のようにURLが生成されるように、RedirectToActionまたはActionLinkでルート値を指定する簡単な方法はありますか?
これらは機能していないようです:
return RedirectToAction("Foo", new { bar = new[] { 1, 3, 5 } });
return RedirectToAction("Foo", new[] { 1, 3, 5 });
<%= Html.ActionLink("Foo", "Foo", new { bar = new[] { 1, 3, 5 } }) %>
<%= Html.ActionLink("Foo", "Foo", new[] { 1, 3, 5 }) %>
ただし、配列内の単一のアイテムの場合、これらは機能します。
return RedirectToAction("Foo", new { bar = 1 });
<%= Html.ActionLink("Foo", "Foo", new { bar = 1 }) %>
bar を配列に設定すると、次のようにリダイレクトされます。
.../Controller/Foo?bar=System.Int32[]
最後に、これは ASP.NET MVC 2 RC を使用したものです。
ありがとう。