Asp.net mvc views and strongly typed viewdata

I prefer strongly typed viewdata for my asp.net mvc views for various reasons, and I actually preferred codebehinds views, as was the case with previous asp.net mvc prerelease versions, because codehind was the natural place to define the podo class viewdata since they usually have a 1: 1 ratio to the actual look.

Is there a way to have a codename in asp.net rtm views or is this not a good approach?

EDIT: The only reason I would like to have code is because I see ViewData as a view property. If a view was a class, then ViewData was one of its properties, and it feels unnatural to define this in a separate assembly.

+5
source share
4 answers

After almost a year, together with MVC, I can confirm that I do not need the code for viewing even once. If you use code, you probably still consider WebForms. Throw it.

Only model data should be displayed in the view. Simple solutions, such as the CSS class to apply, can run directly in the view in server tags. More complex decisions should go to the controller or business logic.

+6
source

I prefer strongly typed viewdata for my asp.net mvc views for various reasons

. NerdDinner FormviewModels 6 , . , .

, , codebehind. , MVC , .

+1

codebehinds MVC.

, -.

, ViewState, .

0

MVC , Web Forms.

MVC , , webcontrol, .

MVC, , .

" ()" → . ( , )

0

All Articles