I have recently seen a .NET MVC solution in which the markup in the .aspx
views which appear to have a Controller as their model i.e the controller seems to be providing the data for the view, and the .ascx
user controls they contain use a separate model. I'm new to MVC and I wanted to find out about a few things I'm not clear on.
An example of how the code is implemented:
UserDetails.aspx
view has markup that shows it's using the UserDetailsController.cs
as the model. It contains RenderPartial("User_Details.ascx", UserDetailsModel)
and passes it the UserDetailsModel
.
Is this the standard/correct way of implementing MVC? Or just one way to implement it?
I also noticed that the classes used as Models appear to be Service classes that have [DataMember]
and [DataContract]
attributes on the class name and properties - what is the advantage of this implementation?