[英]Asp.Net Core 3-1 - Returning Guid to other Action view at controller?
I have two actions 1- action:我有两个动作 1- 动作:
public IActionResult ShowFirstSubCategory(Guid category)
{
var firstsubcategory = _admin.ShowFirstCategory(category);
return View(firstsubcategory);
}
2-action: 2-动作:
public IActionResult EditFirstSubCategory(Category firstsubcategory)
{
if (!ModelState.IsValid)
{
return View(firstsubcategory);
}
_admin.UpdateMainCategory(firstsubcategory);
return View("ShowFirstSubCategory", firstsubcategory.ParentId);
}
I want firstsubcategory.ParentId
send to action view ShowFirstSubCategory
我想要
firstsubcategory.ParentId
发送到操作视图ShowFirstSubCategory
And get the amount in the action...并在行动中获得金额......
You are trying to show another view that has a different model than that the parameter you passed into it.您正在尝试显示另一个视图,该视图的 model 与您传递给它的参数不同。 Instead, you should be using
RedirectToAction
like below:相反,您应该使用
RedirectToAction
,如下所示:
return RedirectToAction("ShowFirstSubCategory", new { category = firstsubcategory.ParentId});
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.