Asp.net mvc 从当前操作导航到其他控制器的操作并显示视图
我有一个产品控制器的动作:Asp.net mvc 从当前操作导航到其他控制器的操作并显示视图,asp.net-mvc,Asp.net Mvc,我有一个产品控制器的动作: public ActionResult SortedLists(List<string> items, string ShopID) { //Do sth... db.SaveChanges(); return RedirectToAction("Index", "ControlPanel", new {ID = ShopID }); } public ActionResult Index(int ID) { View
public ActionResult SortedLists(List<string> items, string ShopID)
{
//Do sth...
db.SaveChanges();
return RedirectToAction("Index", "ControlPanel", new {ID = ShopID });
}
public ActionResult Index(int ID)
{
ViewBag.theRelatedShopID = ID;
return View();
}
我追踪代码。已呈现索引页,但浏览器中未显示任何内容。只是在URL中添加了一个“#”,如下所示:http://localhost:55161/#
。为什么我看不到这一页
页面索引不是强类型。请尝试通过TempData传递值。TempData与ViewData非常相似,但用于跨请求传递值 例如,试试看
TempData["ID"] = ShopID;
只需提醒一句,在控制器操作中使用TempData将使单元测试更加困难