Model-View-Controller framework for ASP.NET in the works

| by Hartmut Wilms Follow 0 Followers on Mar 17, 2007. Estimated reading time: 2 minutes |
At the MVP Summit Scott Guthrie presented a prototype for a Model-View-Controller framework, which might make its way into ASP.NET, in a special meeting arranged by Jeffrey Palermo.

The Model-View-Controller framework is centered around the Controller. In the Java world Struts is a very popular example of an MVC Web Application Framework. The general idea is that the controller is responsible for the navigational code, i.e. it controls the application flow. The view simply renders the information stored in the model. Although MVC provides a certain level of separation of concerns, the view is often tightly coupled to the model. On the other hand the application flow is separated from the view, thus providing better means of reusing views as well as a cleaner web client implementation.

Jeffrey Palermo describes how the MVC framework prototype works:

With Scott's prototype, there is a new handler factory that infers from the URL which controller to instantiate and load. The controller then decides what to do with the request. The controller can load a view (.aspx file) and let it render. The view can access properties of the Controller. The ASP.NET lifecycle and control model and still be used in the view, or you can let the Controller render a view of customized templates. Either way, the Controller is in control.
Besides supporting separation of concerns, MVC allows for an easy way of unit testing web clients. The flow of actions can be tested without instantiating (real) views; mock views can be used instead.

Joost gives some explanation of the Model View Controller pattern in web applications in his article, also naming the pros & cons:
  • What's so useful about it
    • Separation of requests and pages
    • Views are dumb
    • Shielding of the Model implementation

  • Problems and limitations
    • What goes where
    • Coupling between View and Model
    • Lots of objects
Today the Model-View-Presenter pattern is used for separating model, view and application flow in the ASP.NET world, e.g. in the Web Client Software Factory. Sometimes MVP is seen as an improvement of MVC, making use of its strengths and at the same time avoiding its disadvantages. Martin Fowler provides a nice overview of current GUI Architectures. Within the article he explains the different paradigms for developing GUIs:
To approach MVP I find it helpful to think about a significant mismatch between two stands of UI thinking. On the one hand is the Forms and Controller architecture which was mainstream approach to UI design, on the other is MVC and its derivatives. The Forms and Controls model provides a design that is easy to understand and makes a good separation between reusable widgets and application specific code. What it lacks, and MVC has so strongly, is Separated Presentation and indeed the context of programming using a Domain Model. I see MVP as a step towards uniting these streams, trying to take the best from each.
Concerning the value of the MVC framework for ASP.NET Jeffrey Palermo concludes:
This is very cool, and ScottGu is headed in the right direction. I'll vouch for that. We're going to end up with a new ASP.NET paradigm that so much easier to work with and, most importantly, easier to test!
What are your experiences with Web Application Frameworks, the MVP or MVC pattern and what do you think of MVC for ASP.NET?

Rate this Article

Adoption Stage

Hello stranger!

You need to Register an InfoQ account or or login to post comments. But there's so much more behind being registered.

Get the most out of the InfoQ experience.

Tell us what you think

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Monorail??? by Rob Eisenberg

Sure. This is moving in the right direction. However, it's still another layer built on top of a poor abstraction. Why not just use Castle's Monorail. It already has all of these features plus tons more. It's tested and proven in the field. It's going to take MS several years before it can catch up with what is already available TODAY in open source frameworks (Castle-Monorail, NHibernate, MbUnit, RhinoMocks, etc.)

Re: Monorail??? by Hartmut Wilms

You're right. Monorail is surely a great framework. But this opens another completely different discussion. The same question might have been asked (and was) concerning NUnit, MbUnit, Log4Net, and several other great OSS tools.

Re: Monorail??? by Ricardo Redder

Definitely Castle is the best framework available for .NET, but it still needs lots of improvements, even though... it's great, and it does MVC, as well as many other things.

Is this the new Rails-style framework people have been whispering about? by Obie Fernandez

I heard at QCon from someone high up in the dark empire that it might be codenamed Blink...

Re: Monorail??? by David Li

The reason is because in a lot of high level corporate environments, open source products are no-no.

Re: Monorail??? by Jeff Santini

But in alot of others they are not. Certainly in the Java world I have never worked on a project in a big corporate environment without some OSS. Hibernate, Ibatis, Spring, Webwork, Freemarker, Velocity are all de rigeur in the high profile Java projects I have been associated with. Have also been involved with NHibernate and Neo being used in .Net projects

Re: Monorail??? by Hartmut Wilms

The main reasons for .NET OOS tools being rejected by "big companies" are that the Microsoft community's activities in the field of OSS development has been weak in the pre .NET era and that Microsoft provides tools on their own instead of supporting the OSS frameworks.
Sun supports Java OSS development, e.g. they are supporting Tomcat as a reference implementation for some of their J2EE specs. There are reasons for both the Microsoft and the Java way of handling OSS development.

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

Allowed html: a,b,br,blockquote,i,li,pre,u,ul,p

Email me replies to any of my messages in this thread

7 Discuss