如果你有一個控制器5個列表視圖,並在每個列表中,你可以去編輯,細節或刪除。 在編輯,詳細信息和刪除頁面youo有一個鏈接'返回列表'。 什麼是最好的方法來「記住」你必須返回哪個列表動作?asp.net的MVC控制器和「返回列表」鏈接
作爲一個解決方案,我已經把像CurrentAction一些信息在視圖模型,並使用在視圖中。但是,如果你想用不同的控制器,而不是一個......用這個 (您可以使用Currentcontroller,CurrentArea,但是這不是一個「美麗」的解決方案)
public class MyController : Controller
{
public ActionResult Index()
{
...
}
public ActionResult List2()
{
...
}
public ActionResult List3()
{
...
}
public ActionResult List4()
{
...
}
public ActionResult Create(...)
{
...
}
[HttpPost]
public ActionResult Create(...)
{
...
}
public ActionResult Edit(...)
{
...
}
[HttpPost]
public ActionResult Edit(...)
{
...
}
public ActionResult Delete(...)
{
...
}
[HttpPost]
public ActionResult Delete(...)
{
...
}
}
感謝
菲利普
即時通訊完全困惑。爲什麼你有5個列表視圖?他們在做什麼? – RPM1984 2011-05-18 07:43:13
完全不同的過濾器領域的不同列(List2,3,4爲了簡便起見,在我的應用我給它適當的名稱) – Filip 2011-05-18 08:28:45