我有相同的
@Html.ActionLink("SUSPEND", "Suspend", "Serials", new { id = s.serial, orderId = s.Order.orderID }, null)
在两个不同的页面上。
假设我可以从此页面点击它:
http://localhost:55058/Customers/Details/4106
并从此页面开始:
http://localhost:55058/Orders/Details/102091
该链接将我带到与两个标准Controller操作相关联的表单,GET:
public ActionResult Suspend(string id, string orderId)
{
Serial serial = context.Serials.Single(x => x.serialID == id);
ViewBag.orderId = orderId;
return View(serial);
}
和POST:
[HttpPost]
public ActionResult Suspend(Serial serial, string orderId)
{
if (ModelState.IsValid)
{
serial.suspended = true;
serial.suspensionDate = DateTime.Now;
context.Entry(serial).State = EntityState.Modified;
context.SaveChanges();
ViewBag.orderId = orderId;
return View(context.Serials.Single(x => x.serialID == serial.serialID));
}
}
一旦我提交表单,我如何Redirect()
到我第一次点击链接的页面 ? 可能,以优雅的方式......
感谢。