Is this the correct way to implement .NET MVC website structure?

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?

6

Based upon the limited description so far, the best answer I can give is “maybe.”

Here’s my partial take on MVC, which generally aligns with others’ takes. But there’s always bones of contention to be had. I would recommend Martin Fowler’s articles as a good starting point with MVC and the other MVx variants.

The View should not be aware of the Model; it only knows what the Controller feeds it.
The Controller is more than welcome to directly pass a data structure from the Model to the View. But the Controller is on the hook to maintain that contract with the View if the Model should change.

In other words, the Controller may retrieve a List of users from the Model and then pass that List directly to the View. In this case, the structures magically aligned and all three layers are able to utilize the same (or similar) structure.

Should the View need additional details later on, then the Controller will be responsible for accessing the Model as necessary in order to provide those additional details back to the View.

2

The basic concept of MVC is:

Model: This is the domain model of your application.
View: This is the User Interface of your application. (you should not put any logic here.)
Controller: This is responsible for the interaction with the user. Pull data from ‘Model’ and select ‘View’ for the user interface.

For more details: http://www.asp.net/mvc/tutorials/older-versions/overview/asp-net-mvc-overview.

You can see the basic folder structure when you create a new ASP.NET MVC application in Visual Studio. Here Controlers are kept in one folder, Models are another and there is a view folder in which you can find many subfolders with the same name of the controllers. Under these folder you can find the views which the perticular controller will use. There is a ‘shared’ folder, under it has the views which can be usable for all the controllers. Microsoft create a convention over configuration concept in ASP.NET MVC. That is why the nameing convention and the folder stucture is essential.

[DataMember] and [DataContract] attributes are related with WCF.

Hope this help.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật