14

I wanted to know the difference between asp.NET MVC and MVP, are they both same? below is the architecture diagram I referred.

(Image URL:http://msdn.microsoft.com/en-us/library/ff647859.aspx)

MVC vs MVP

the major difference I got to know between MVC and MVP from the diagram is, in MVC the Model updates the view and in MVP the Presenter updates the view.

But here is my confusion.Below is a asp.net MVC code sample.

public class HomeController : Controller
    {
        //
        // GET: /Home/

        public ActionResult Index()
        {
            return View();
        }

    }

here the Controller returns/updates the view so now according to the diagram it is MVP

Is asp.net mvc and MVP similar? if not what is the difference ?Can someone guide me.

Dalton
  • 1,334
  • 1
  • 11
  • 19
  • 1
    That MVC diagram looks misleading to me. – Liam Nov 15 '13 at 08:58
  • 1
    possible duplicate of [What are MVP and MVC and what is the difference?](http://stackoverflow.com/questions/2056/what-are-mvp-and-mvc-and-what-is-the-difference) – Liam Nov 15 '13 at 08:58
  • 3
    Your question is confusing *ASP.Net MVC* is a *framework* based on the MVC pattern and *MVP* is a pattern. So did you really mean to put this in context of ASP.Net? – Chris Moutray Nov 15 '13 at 09:09
  • I was studying Asp.net mvc so I put it in that way....instead of only MVC. – Dalton Nov 15 '13 at 09:17
  • That MSDN page pre-dates Asp.Net MVC. It's from **2005** and is for the *Composite UI Application Block* whatever that is... http://msdn.microsoft.com/en-us/library/ff648900.aspx – Liam Nov 15 '13 at 09:18
  • @Liam I referred that site only for the diagram...and nothing else. ;-) – Dalton Nov 15 '13 at 09:23

4 Answers4

9

Actually MVP is a subset of MVC pattern.

In your example of asp.net mvc the controller does not updates the view rather it just pass the model to the view and the view get updated according to the model.

But in MVP (which is usually used with winforms and webforms in Microsoft stack) the presenter get data from view, updates the model and when the model changed, the presenter will read the model and updates the view.

VahidNaderi
  • 2,448
  • 1
  • 23
  • 35
4

That MVC diagram looks misleading to me. I would regard this as a more actuate architectural diagram:

enter image description here

this is from a PHP site but here you can clearly see the relationship between the view and the controller.

The differences between MVC and MVP are subltle, this question (as mentioned above) clarifies those differences.


That MSDN page also clearly says

This content is outdated and is no longer being maintained. It is provided as a courtesy for individuals who are still using these technologies....

I think this resource pre-dates Asp.Net MVC.

The articles themselves are for something call the Composite UI Application Block and are from 2005. I'd go to http://www.asp.net/mvc/ for some more up to date and acurate information on MVC.

Community
  • 1
  • 1
Liam
  • 27,717
  • 28
  • 128
  • 190
  • I used that page only for the diagram (it had both MVP and MVC together)....many other pages also show a similar diagram....btw I refer Pro ASP.NET MVC 4: Adam Freeman book for mvc... – Dalton Nov 15 '13 at 09:31
0

No.They are not the same. They are two different paradigms (design patterns) used for user interaction. Based on these paradigms, ASP.NET team developed two different frameworks for writing web applications. The first is ASP.NET Web Forms based on an event based form programming. The second is ASP.NET MVC which is based on using Model Views and Controllers (MVC).

I suppose you could start reading here which is written by one of the ASP.NET development team members.

Regarding the specific question. I think that the Controller updates the View using the Model to do it. Model does not do anything. Or this is the way I understand it, anyway...

Hope I helped!

Pantelis Natsiavas
  • 5,293
  • 5
  • 21
  • 36
  • ASP.Net did not develop these patterns. They've been around long before Microsoft touched them. – Liam Nov 15 '13 at 09:00
  • 1
    You are right. I said "ASP.NET team developed two different frameworks for writing web applications". I hope I did not imply that the design patterns where developed by Microsoft. Thank you for clarifying. – Pantelis Natsiavas Nov 15 '13 at 09:02
  • 1
    But my confusion was between MVC and MVP not between asp.net webforms and MVC. – Dalton Nov 15 '13 at 09:03
  • Yes, this doesn't answer the question at all. – Liam Nov 15 '13 at 09:08
  • and now it's inacurate also *Model does not do anything.*. Yes the Model does do something, it holds the data. – Liam Nov 15 '13 at 09:09
  • I just edited it, adding two lines. Being in a hurry, I accidentally deleted some text. Hope my opinion is clear now... – Pantelis Natsiavas Nov 15 '13 at 09:10
0

Try to understand MVC and MVP concept without connection to any technology.

Action method in ASP.NET MVC controller returns ActionResult with View method doesn't break any pattern. It just say that controller functionality is done and let's render the view from markup with Razor/ASP.NET syntaх.

In ASP.NET world - ASP.NET MVC is impelemntation of MVC pattern. Forgotten Web Client Software factory is MVP implementation

Regfor
  • 8,515
  • 1
  • 38
  • 51