views:

130

answers:

2

Is it best to create a separate view for authorized and unauthorized even if there will not be a lot of additional information in the authorized view? Or should there be one view and with model data adjusted accordingly?

EDIT: In MVC, I believe it better to have 2 views and then use partial views for the duplicate information. agree?

+1  A: 

There is no "the best" solution. It's all depends on the situation. As for me I used not to create "almost identic" Views without important reason.

UPDATED:

I think fist you should try "adjusting" the ViewModel in the Controller and then passing it to the View. This makes your Views "more general"

eu-ge-ne
+1  A: 

I use a single view for both authenticated/unauthenticated states. I have helpers for the parts of the view that are for authenticated users only.

For example: if i have a "New Contact" link that i need to render onto the view but it should only be visible to authenticated users, then i'll use my helper (something like this):

<% =Html.RenderNewLink() %>

..that helper will first check if the user IsAuthenticated before it renders anything.

I'll have these types of helpers scattered throughout my views in the places where, for authenticated users, there would need to be more markup. And so, for the un-authenticated users, those places are blank/empty.

I hope this makes sense.. prob not the best way to explain it.

cottsak