tags:

views:

56

answers:

1

Is the following code sane?

public ActionResult MyController()
{
    using(var model=new MyControllerModel())
    {
        return View(model);
    }
    //does framework access model after this point? 
    //If so, I need to rethink

}
+4  A: 

The framework most definitely accesses the model after it returns an ActionResult. ActionResults have their Execute() methods called in order to generate the content.

womp
This is correct. If you need to dispose of anything within the controller, you can override Controller.Dispose(). You can dispose of your model from within that method.
Levi