Sanqiang Zhao
Sanqiang Zhao

Reputation: 307

need i create one model for each view in MVC4

Actually i am new learner for MVC4, my boss want to change the old asp.net webform to MVC4. that i have some problems. one is for each view is that need to create seperate model? for example, in login page, users just put their name and password and submit. so in order to receive those name and password, need i create one model for that name and password, namely one auth class with two class member, name and pass.

Or is there any better way to transfer old one to MVC

Upvotes: 0

Views: 85

Answers (1)

Jakub Konecki
Jakub Konecki

Reputation: 46008

What you're talking about is a View Model - a class that represents your view / form. Instance of this class will be passed as a parameter to your Login action and will contain username and password. You will usually name your view model class after the view, eg. LoginViewModel.

It is an accepted way to create MVC applications.

Upvotes: 1

Related Questions