Virtual Classes
Read Anytime,Anywhere
Home
Knowledge
English
Grammar
Essay
हिंदी
व्याकरण
निबंध
Physics
Computers
MVC
Oops
JQuery
C++
ASP.NET
Interview FAQ
Download
Contact Us
Model
View
Controller
Layout Page
Partial View
Razor View Engine
Model Binding
Bundling In MVC
Routing in MVC
Request Life Cycle
ViewData\ViewBag
Filters
Model
A model is a class which holds the data. A model basically act as a facilator/intermediator between View and Controller. When a controller wants to send some data to view it uses model to pass the data, when view wants to pass data to controller it uses model. A model holds all the required information that is needed to render the view.
To add a model to your MVC application.
1-Goto to solution explorer --> Right Click on Model folder-->Choose Add-->Choose Class
Belog image shows adding a model to a MVC application.
2-A dialog box will be opened. Give a name to the class and Click on "Add" button.
3- Add Properties to the class.
A model hold the data to render view so add only those properties which are needed to render the view.
I have created a Student model, this model has four property StudentID,StudentName,ContactNo and Address.