Question

I am working on an ASP.Net MVC application, and its architecture consists of the usual DAL, BL, and PL layers.

Addresses are stored as separate fields in the database, but shall be displayed in a single field in the UI.

When it comes to displaying, I need to handle various optional fields (e.g. state, country, several lines for the address).

My question: should this calculation of the effective display string be handled by the controller or by the view? Does the MVC paradigm offer some rules or recommendations for this question?

Was it helpful?

Solution

Your controller shouldn't know anything about how the addresses are displayed - since you might have different views that call into the same controller action that want to render the address differently. It is the concern of your view as to how the address is rendered for a particular purpose

OTHER TIPS

In a proper MVC design pattern, the view should decide what information will be displayed and how. Controller should only be responsible for changing that state of model layer and current view.

But it might not be possible, due to heavy Rails influence on ASP.NET MVC framework, because you might not have a real view. Just a dumb template. And those two are not the same thing.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top