In ASP.NET MVC (3.0/Razor), do you prefer multiple views, or conditionals within views? Why?
- by Chad
For my new web app, I'm debating on using multiple views, or conditionals within views.
An example scenario would be showing different info to users who are authenticated vs non-authenticated. This could be handled a couple ways.
In the controller, check IsAuthenticated and return a view based on that
In the view, check IsAuthenticated and show blocks of info based on that
Pros of multiple views: Smaller, less complicated view - next to no logic in the view
Pros of single views: less view files to maintain
The obvious cons are the opposites of the pros: more files to maintain or more complicated view files.
Which do you prefer? Why? Any pros/cons I haven't outlined here?
Update: Assume each view uses a layout page and partial views to abstract the obviously repetitive code.