Pass data between controllers

Aug 5, 2010 at 8:41 PM
Hello, I have some problem with pass data between controllers (forms), from controller x i navigate to y controller which execute view with edit form, after editing form by user i goBack. How to retrive data from Model in y controller after go back. Best regards
Aug 5, 2010 at 10:24 PM
Edited Aug 5, 2010 at 10:27 PM
Hello, You can use the container to centralize all your model classes, and then use that to access.
For each controller, set a property for the container to gain access all the models.

On the example of the source code:

public class LoginController : Controller
public Container Container


container.Register<LoginForm>(c => new LoginForm());
container.Register<LoginController>(c => new LoginController(c.Resolve<LoginForm>()))
.InitializedBy((c, v) => v.Container = c);

container.Register<ModelClass>(c => new ModelClass());

On any controller: