【发布时间】:2026-01-12 23:25:02
【问题描述】:
我拥有这个网站:http://www.sohjel.ir;我使用 ASP.NET Core 2.1 MVC Session 实现了一个名为“Watch Bag”的选项。 我的问题是:单击此按钮并将该课程添加到“Watch Bag”而不是返回到“Begin of Page”后,我想返回到单击该页面中的“Add To Watch Bag”的确切位置。 我怎么做?! 请注意,我在控制器中使用了此代码:
[HttpPost]
[ValidateAntiForgeryToken]
public async Task<IActionResult> Index(int id)
{
List<int> lstViewBag = HttpContext.Session.Get<List<int>>("sjViewBag");
if (lstViewBag == null)
{
lstViewBag = new List<int>();
}
lstViewBag.Add(id);
HttpContext.Session.Set("sjViewBag", lstViewBag);
return RedirectToAction("Index", "Home", new { area = "Customer" });
}
【问题讨论】:
-
可以使用anchor,看这个问题:*.com/questions/602788/…
-
或者....*.com/questions/484463/…(查看未接受的答案)
标签: asp.net-core asp.net-core-mvc