BT

InfoQ Homepage News Model-View-Presenter for Web Forms

Model-View-Presenter for Web Forms

Bookmarks

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
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.

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

Community comments

  • wrong

    by Hrvoje Hudoletnjak /

  • Your message is awaiting moderation. Thank you for participating in the discussion.

    "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

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

BT

Is your profile up-to-date? Please take a moment to review and update.

Note: If updating/changing your email, a validation request will be sent

Company name:
Company role:
Company size:
Country/Zone:
State/Province/Region:
You will be sent an email to validate the new email address. This pop-up will close itself in a few moments.