次のような「Thingy」コントローラーがあります。
[HttpPost]
public ActionResult DeleteConfirmed(long? id) {
// <Validate ID, delete associated records>
return RedirectToAction("Index", "Thingy");
}
ただし、RedirectToAction
ルート値にパラメーターからのIDが入力されたままになりますが、IDをnullのままにして、www.mywebsite.com/Thingy
代わりににリダイレクトする必要がありますwww.mywebsite.com/Thingy/1
実際、私はwww.mywebsite.com/Thingy
直接アクセスでき、期待どおりに機能します。
私が試してみました:
RedirectToAction("Index", "Thingy")
RedirectToAction("Index", "Thingy", new { })
RedirectToAction("Index", "Thingy", new { id = (long?)null })
www.mywebsite.com/Thingy?id=1
他の人が にリダイレクトするのと同じようににリダイレクトするので、最後のものは特に面白いですwww.mywebsite.com/Thingy/1
。