How do I translate this webforms paradigm into mvc?

Take the following hypothetical situation, how would you implement it in MVC?

All my pages sit in the Master, it has a CurrentUser property. This object is determined from some session user id and then requested from db on every page load. This object is then used throughout the site, for example to display "Greetings _____" at the top and used in various page codes as part of database queries, and so on. There are several custom controls on the same page, each displaying different information that is requested on first load. When one control bounces back and somehow changes its display, the rest of the page remains unchanged without having to repopulate it.

I am getting the basics of mvc, however I am struggling to figure out how to get to the next (real world) level of rich presentation content. How do you open shared objects for viewing? Does the controller have to store every bit of data it might need to view in the ViewData?

Can anyone recommend a good tutorial on more advanced mvc usage that will help me figure out how to move away from web forms?

+1


source to share


1 answer


I prefer to put all the data I need to view in ViewData. I have been trying to use a strongly typed model most of the time, and have had some success in adding the generic properties used in my application to the generic BaseViewData class.

For general properties such as user information, I've let the BaseViewData class be responsible for populating or providing these property values ​​so that each controller doesn't have to worry about contextual information that isn't necessarily associated with a specific action.



I am interested to know how others have solved the problem.

+2


source







All Articles