Comparison of the ASP.net MVC framework and the MVP model in WCSF

Source: Internet
Author: User
Tags comparison actionlink

Overview

The MVC pattern has been around for decades and has been widely used in the GUI field, which has made MVC a hot topic for the. NET community since the advent of the Microsoft ASP.net MVC framework. The variant MVP model of MVC has been around for several years, and in the Web Client Software factory provided by the Microsoft mode and practice team, the application best practices for MVP mode are given, and this article will try to compare these two implementations by one or two.

MVC (Model-view-controller, model-View-Controller) mode is a software design pattern appearing in the 80 's Smalltalk-80, and has been widely used, and its main purpose is to promote the clear separation of the attention between the model, view and controller in the application. The MVP (Model-view-presenter, model-view-representation) pattern, developed by IBM, is a programming model for C + + and Java, probably appearing in 2000, and is a variant of the MVC pattern, primarily used to isolate UI, UI logic, and business logic, data. In the following text, if not specifically stated, MVC refers to the asp.net mvc Framework.

Processing process

For the difference in the processing process, use the following two pictures to illustrate everything:

Figure 1:model-view-controller

Figure 2:model-view-presenter

Processing process, in MVC, the user's request will first arrive controller, from the model to obtain data from controller, select the appropriate view, the processing results presented to view; In the MVP, the user's request first arrives in view, The view pass request to a particular presenter,presenter gets the data from model, then passes the processing result through the interface to the view.

View differences

The view in the ASP.net MVC framework can be a asp.net page, a user control, or a master page. Need to separate s to inherit ViewPage, Viewusercontrol, ViewMasterPage. Sample code:

public partial class Views_Blog_New : ViewPage
{

}

Using inline code for data rendering, and of course, you can use server controls, sample code:

<%=Html.ActionLink("Home", "Index")%> |
<%=Html.ActionLink("New Post", "New")%>
<div>
  <%foreach (Post post in ViewData)
   { %>
   <div class="postitem">
    <strong>Title</strong>:<%=Html.Encode(post.Title) % ></br>
    <strong>Author</strong>:<%=Html.Encode(post.Author) %></br>
     <strong>PubDate</strong>:<%=Html.Encode(post.PubDate.ToShortDateString()) %></br>
     <strong>Content</strong>:<%=Html.Encode(post.Description) %></br>
    <% =Html.ActionLink("Edit", new {action="Edit", Id=post.Id })%>
  </div><br />
   <% } %>
</div>

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.