I read the Pro .Net Asp.net MCV book over the weekend and it provides some good examples on setting it up and using it. However my question is what is the structure of an MVC project should be. I ran into problems once I started trying to transfer control from one controller to another. It seems that you can have multiple views within one controller. Also when you execute the Redirect("Action", "Controller") command it see开发者_如何学Cms that the routing wants to look for the view within a sub of that controller. So my questions are:
- Is there rule of thumb of 1 controller to 1 view?
- Should you call another controller from a controller?
- What is the proper way to transfer control from one controller to another?
- You can have as many views/partial views per controller. The rule of thumb as far as one can deduce it from the MVC samples is, that a controller encapsulates a set of functionality that belongs together, e.g. listing products and creating, updating, deleting as single product.
- You can use Html.ActionLink to route from one view to another. To call one controller from another, IMHO, makes only sense for partial views - however that depends on the problem.
- Html.ActionLink or Html.RouteLink.
精彩评论