.NET MVC:调用RedirectToAction传递一个模式? [英] .NET MVC : Calling RedirectToAction passing a model?
本文介绍了.NET MVC:调用RedirectToAction传递一个模式?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我绑定到类视图 List.aspx
幼儿园
在控制器:
public ActionResult List(int Id)
{
Kindergarten k = (from k1 in _kindergartensRepository.Kindergartens
where k1.Id == Id
select k1).First();
return View(k);
}
这工作的。
但是,这并不
[AcceptVerbs(HttpVerbs.Post)]
public ActionResult Add(...)
{
//...
Kindergarten k = ...
return RedirectToAction("List", k);
}
我应该怎样重定向到列表视图,通过K作为模式?
How should I redirect to the list view, passing k as the model?
谢谢!
推荐答案
我觉得你只需要调用视图像
I think you just need to call view like
返回RedirectToAction(列表,新
{ID});
return RedirectToAction("List", new {id});
id为需要填充的幼儿园。
with id you need to populate the Kindergarten.
这篇关于.NET MVC:调用RedirectToAction传递一个模式?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文