Typically, an action method will end with something like this:
return View(new Model());
But if my model is going to have services injected, it won't have a default ctor. So it would have to look like this:
return View(new Model(new Service());
But if the service has dependencies it'd be more like this:
return View(new Model(new Service(new Repository())));
...which starts to get ridiculous. Isn't this what a IoC container is for? So I'd be tempted to write something more like this:
return View(container.Resolve<IModel>());
but in order to get container
it would have to be injected into my controller, and I hear that injecting the container itself is an anti-pattern.
So what is the right way? How do I pass my dependencies to my model when I return the view from the action method?