简体   繁体   中英

What all logic should be written inside controller?

I am part of a team who is developing a program in C# which utilizes MVC architecture.

While i went through MVC tutorial i have some doubts. Please help me clarify this doubts.

1) What all modification in the view can be done by Controller?

2)I believe all UI modification(such as changing the text fore color when a threshold is met) need to be done in the view level as the model does not have any direct contact with controller.Is this correct?

3) I see a dotted line connecting the model to view indicating an 'indirect'relationship. Can you please explain what is that indirect relationship means?

Thanks in advance,

At first a controller should be thin for better readability. At best it should only delegate things.

1) You should try to keep your view as simple as possible by trying to avoid complex logic in the view. Try to build HtmlHelper extensions or try to create an extra component that is repsonsible for the one complex concern. The controller should then delegate to the component.

2) Yes, but look at 1).

3) The model does not know the view, but the view knows the model.

Have a look at: http://lostechies.com/jimmybogard/2009/04/24/how-we-do-mvc/

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM