views:

320

answers:

3

Typically, in sites that allow membership, you want to offer your users a bit of data that is only visible when they're logged in.

For my site, if the logged in user is the data owner, I want to offer some tools to let them manage the data.

My question is this. Do you split this duty between two different views? One view that gets loaded for "regular" users, the other that gets loaded for "owner" users. The view that the regular users see simply shows the data. The owner sees the data and some tools to manage it.

Or, do you perform checks in a single view and hide/show blocks within it (similar to what you would have done in regular ASP.NET)?

It's probably by preference, but are there any technical reasons for splitting the duty between two views vs a single view?

+1  A: 

Personally I would go for the single view option. That way you don't have to repeat code that'll appear in both views.

Technically (or in regards to the MVC pattern) I can't think of any reasons to split it up.

Charlino
The only reasons I would think to split it up would be to remove any logic code from the view, or if you needed to split the work up to different designers.
Chad
+4  A: 

I would also go for the single view option as well. Would provide specific properties on your viewdata to indicate what to do.

<% if (Model.IsOwner) { %>
    //Html for owner
<% } %>
Schotime
That is exactly what I do in my views, literally. IsOwner is the exact property I pass to the view as well. :D
Chad
A: 

I would be inclined to split the view into multiples as ideally you want to avoid conditional logic in a view (read: ideally).

If you find that would cause some duplication between your views, then it's likely that you could move that duplicated content into shared partials.

Derek Lawless