I have a windows forms project using the Model View Presenter pattern and would like to build a web forms project on top of the same MVP structure.

The windows forms project knows nothing of ASP.Net Membership and just communicates via the presenter to the model and then to the business layer to do user log on/validation. In the web forms project I have created custom classes that inherit from the built in membership and role provider classes so that I can use the existing user and roles tables as well as integrate nicely with the ASP.Net login controls. However, currently I have had to reference the business layer directly in the custom membership class to validate users, so if I follow MVP, the membership code shouldn't be in the view with references to business layer, it should be in the model but that means referencing System.Web.Security in the model.

Is there a way to still use ASP.Net membership with MVP where the webforms and winforms projects are built on top of the same MVP structure? I think I need to pass in the dependency on membership to the presenter and then to the model but can't quite see a clean way to do this.

One of the commonly mentioned benefits of MVP is that it allows for building different UI's on top of the same presenters, models, etc. However, in practice, does this really work well or is it best to implement MVP separately per UI technology?

Also in relation to the web forms project, is Session state something that the view can just deal with or does this need wrapping with a custom class and interface and passing to the presenter to maintain?

  • I might be missing something, but can't you add an ASP.NET membership project and then make a generic interface for your members between Webforms and Winforms?
    – Hexxagonal
    Commented Mar 29, 2012 at 14:07
  • @Hexxagonal - where would the asp.net membership project be referenced from? Model -> ASP.Net Membership? What happens when the logon request is coming from windows forms project?
    – Matt F
    Commented Mar 29, 2012 at 14:28

1 Answer 1


I was thinking of something like this.

Potential Package Layout

Where "Webforms User Stuff" would depend on System.Web.Security and "Generic User Stuff" would have your flavor of access control. Don't directly use ASP.NET membership but use composition.

  • I see what you mean about placing the membership code and dependency in the 'Webforms User Stuff' project but with model view presenter, both webforms UI and winforms UI projects will share the same presenter and model, so my question is how does the model get the correct object to validate the user e.g. when logging on via web client the model uses an object that uses ASP.Net membership but when logging on via windows client it uses an object that just goes directly to business logic?
    – Matt F
    Commented Mar 29, 2012 at 15:01
  • I may be over complicating things just so I can use the ASP.Net login controls but it seems much easier to get the login and login status controls working properly when using membership.
    – Matt F
    Commented Mar 29, 2012 at 15:02
  • I don't think it is that much more work to extract out the "generic" user logic from the winforms/webforms specifc user logic, but then again I have never seen your project. If you are not set on ASP.NET membership, you can create your own custom Membership Provider in ASP.NET. msdn.microsoft.com/en-us/library/aa479048.aspx
    – Hexxagonal
    Commented Mar 29, 2012 at 15:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.