BT

Model-View-Presenter for Web Forms

| by Jonathan Allen Follow 576 Followers on Jun 07, 2011. Estimated reading time: 1 minute |

While it is possible to use a MVC-style architecture with ASP.NET Web Forms, most find it to be a clumsy match. The rich components and stateful nature of Web Forms simply doesn’t mesh well with the MVC pattern. Yet developers still long for the separation and testability that MVC offers. This is where the open source project Web Forms MVP comes into play.

The principal goal of Web Forms MVP is to offer much of the control that ASP.NET MVC offers while still maintaining the high level of productivity you get from using rich controls. In the simplest case Web Forms MVP simply requires the developer to move their logic out of code-behind files and into presenters.

Web Forms MVP claims to be especially good at composing pages. Rather than having a single page and action controller, Web Forms MVP encourages developers to break up their pages into separate reusable components. Each component is considered to be its own view and has its own matching presenter. Presenters are meant to be small and largely independent, though they can communicate with one another.

This framework was also built with Inversion of Contorl and Dependency Injection in mind. The official release contains integration libraries for Castle and Unity. The companion project, Web Forms MVP Contrib, offers support for Ninject, StructureMap, and Autofac.

Since the bulk of the logic is moved into the presenters you can perform automated tests on them using the same techniques you would use if you were testing controllers or view-models in other frameworks. Much of the underlying framework that makes this possible comes from the System.Web.Abstractions library originally introduced with ASP.NET MVC.

Rate this Article

Adoption Stage
Style

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

wrong by Hrvoje Hudoletnjak

"most find it to be a clumsy match"; you couldn't be more wrong! MVC is best thing happened to ASP.NET! Let's don't talk about other MVC frameworks that was before official one, but community is forming and finally we're one right track.

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

1 Discuss

Login to InfoQ to interact with what matters most to you.


Recover your password...

Follow

Follow your favorite topics and editors

Quick overview of most important highlights in the industry and on the site.

Like

More signal, less noise

Build your own feed by choosing topics you want to read about and editors you want to hear from.

Notifications

Stay up-to-date

Set up your notifications and don't miss out on content that matters to you

BT