Asp.Net 核心 3-1 - 将 Guid 返回到控制器的其他 Action 视图?
Asp.Net Core 3-1 - Returning Guid to other Action view at controller?
我有两个动作
1- 动作:
public IActionResult ShowFirstSubCategory(Guid category)
{
var firstsubcategory = _admin.ShowFirstCategory(category);
return View(firstsubcategory);
}
2 动作:
public IActionResult EditFirstSubCategory(Category firstsubcategory)
{
if (!ModelState.IsValid)
{
return View(firstsubcategory);
}
_admin.UpdateMainCategory(firstsubcategory);
return View("ShowFirstSubCategory", firstsubcategory.ParentId);
}
我想要firstsubcategory.ParentId
发送到操作视图ShowFirstSubCategory
并获取行动中的金额...
错误:
您正在尝试显示另一个视图,该视图的模型与您传递给它的参数不同。相反,您应该像下面这样使用 RedirectToAction
:
return RedirectToAction("ShowFirstSubCategory", new { category = firstsubcategory.ParentId});
我有两个动作 1- 动作:
public IActionResult ShowFirstSubCategory(Guid category)
{
var firstsubcategory = _admin.ShowFirstCategory(category);
return View(firstsubcategory);
}
2 动作:
public IActionResult EditFirstSubCategory(Category firstsubcategory)
{
if (!ModelState.IsValid)
{
return View(firstsubcategory);
}
_admin.UpdateMainCategory(firstsubcategory);
return View("ShowFirstSubCategory", firstsubcategory.ParentId);
}
我想要firstsubcategory.ParentId
发送到操作视图ShowFirstSubCategory
并获取行动中的金额...
错误:
您正在尝试显示另一个视图,该视图的模型与您传递给它的参数不同。相反,您应该像下面这样使用 RedirectToAction
:
return RedirectToAction("ShowFirstSubCategory", new { category = firstsubcategory.ParentId});