As I understand it, in ASP.NET MVC a httprequest is mapped to a controller/action.
- As one request is used to get one web page, could we call to these controllers “
page controllers“?
My other question is about widgets (user controls) and RenderPartial method:
- If a widget represents a classic ASP.NET
webcontrolorusercontrol, and I want to render this widget in a lot of pages, how could I avoid repeating the logic of the widget if this logic is in the “page controller“?
Why would you? They’re named controllers. After all, an action on a controller doesn’t neccessarily serve a “web page”, it might respond using JSON data, XML, RSS or only a part of a web page (a ‘control’ if you want).
ViewModelwhich contains the ViewModels needed in the widgets, e.g.–
I felt this unelegant first, but I’ve been using this for some time now and I believe it nicely encapsulates the necessary data.
Hope that helps