Passing values from controller to view and back
Posted on 2010-11-10
I'm developing a web app through ASP.NET MVC.
I have several listings that calls controller methods over business elements to edit or erase them. Usually, when an element is erased, controller returns execution to the list (so
users can see their erased element is out of the list).
And here comes the question. I have several different listings that can show the same business elements (I mean, there are lists that filter in different ways or show different data of
same business elements) and I want to make controller know where to return when an element is erased (so if I call it from a determinated list I want the eraser controller to come back
to it when finished).
So I'm thinking in the best approach for this. I'd like to use some sort of "session variable" to store at any moment the last listing executed, this way any controller could determine when it has to call a listing wich one must be called.
However I'm not very used yet to work in ASP.NET MVC and the only way I'm seeing is to adding a new parameter to controller methods with this "last listing" value, passing it to views through ViewData and back to controllers into the forms or links that
However I'm sure it should be an easier way.