私はMVC asp.netで作業しています。私はingredientIndex
アクションにIDを渡したいRedirectToActionでパラメータを渡す方法はありますか?
public ActionResult ingredientEdit(int id) {
ProductFormulation productFormulation = db.ProductFormulation.Single(m => m.ID == id);
return View(productFormulation);
}
//
// POST: /Admin/Edit/5
[HttpPost]
public ActionResult ingredientEdit(ProductFormulation productFormulation) {
productFormulation.CreatedBy = "Admin";
productFormulation.CreatedOn = DateTime.Now;
productFormulation.ModifiedBy = "Admin";
productFormulation.ModifiedOn = DateTime.Now;
productFormulation.IsDeleted = false;
productFormulation.UserIP = Request.ServerVariables["REMOTE_ADDR"];
if (ModelState.IsValid) {
db.ProductFormulation.Attach(productFormulation);
db.ObjectStateManager.ChangeObjectState(productFormulation, EntityState.Modified);
db.SaveChanges();
**return RedirectToAction("ingredientIndex");**
}
return View(productFormulation);
}
:
は、これは私のコントローラのアクションです。これどうやってするの?
このIDを使用したい他のページから来ているpublic ActionResult ingredientEdit(int id)です。実際には私はid
を第二のアクションで持っていないので、どうすればいいのか教えてください。
卿、私の編集した質問をご確認ください。 –
すべてのビューにidを渡す必要があります –