Asp.net MVC
-
What's the difference between 'model' and 'Model' in Asp.net MVC
-
What's the difference between 'model' and 'Model' in Asp.net MVC
Model
represents the object (instance of the class) in yourmodel
. For example, if your model is created as,namespace Sample.Models {
public class Program {
public string Name { get; set; }
}
}@model Program
// Then in your code
This would write the value of
Name
in the paragraph.The shit I complain about It's like there ain't a cloud in the sky and it's raining out - Eminem ~! Firewall !~
-
What's the difference between 'model' and 'Model' in Asp.net MVC
"model" is only used in the page directive at the top of the view to dictate which class the view uses for its model
@model MyClass
In the view itself Model represents the model that was passed to the view by the controller;
return View("MyView.cshtml", instanceOfMyClass)
So in the MyView.cshtml view code Model will represent instanceOfMyClass