0
Url.Action()
を除き、アクションのためにRedirectResult
を返したいとします。私は次のものを持っているとしよう:Controller
。Return ActionResult as 301
public class CustomerController : Controller
{
public ActionResult Index()
{
var url = Url.Action("CustomerAndProduct", new { customerId = 1, orderId = 2, productId = 3});
return Redirect(url);
}
public ActionResult CustomerAndProduct(int customerId, int orderId, int productId)
{
// I want to get here...
}
}
私は手動で文字列を使用して、アクション名とすべてのパラメータの両方を指定せずにRedirectResult
を返すことができる方法はありますか?その理由は、アクション名またはパラメータ名が変更された場合、これらの文字列を維持するのが面倒だと感じているからです。コンパイル時には検出されません。おそらく、そのような
:
var url = Url.FromAction<CustomerController>(x => x.CustomerAndProduct(1, 2, 3));
return Result(url);
1は、Futures libraryで行うことができる非常に多くのように:私はCustomerAndProduct
を実行したくない
Html.BeginForm<CustomerController>(x => x.CustomerAndProduct(1, 2, 3))
注意。私はちょうど301
または302
としてURLを返すしたいと思います。
100+クラブへようこそ。 ;) 良い例え。しかし、私は第三者を最小限に抑えようとしており、既にFuturesを使用しています。これは、ほとんどのヘルパーにとって同じことを提供します。 – smoksnes