0

I always used asp.net webforms with the MVP pattern, it works great for what I need, I basically create a project where all my business rules reside, validation etc... and I then implement my views in the webforms project.

Now we're starting to use asp.net MVC and using the MVP patter doesn't make much sense, right? So what could be a good approach to create a scalable and testable project using MVC that won't make me create my data objects and do validation on the controllers. I don' want to have the same code in different places...

If a web user wants to update his/her profile on the site, there would be some validation rules for when a submit button is pushed, like email address cannot be empty, must be valid and must not exist in the database.

These same rules should be applied if I try to update his profile using the internal admin section without having to duplicate the code there...

If you can point me to a good sample project that deals with this would be great!

Thanks in advance!

tereško
  • 58,060
  • 25
  • 98
  • 150
Gustav
  • 413
  • 1
  • 5
  • 9
  • 1
    The reason some people might find this question confusing is that MVC is a pattern. In the same way that you wouldn't ask: "What pattern do I use with the Singleton pattern?" it does not make sense to ask what pattern to use with MVC. – Jim Counts Jun 15 '11 at 14:13

3 Answers3

5

You should use the MVC pattern with ASP.Net MVC.

SLaks
  • 868,454
  • 176
  • 1,908
  • 1,964
1

The NerdDinner tutorial is a pretty detailed example for MVC, you can also get a book that includes the tutorial (you might want to wait for the version that covers ASP.Net MVC 3). There are plenty of resources on Microsoft's ASP.Net site.

You can always consult Google.

Jim Counts
  • 12,535
  • 9
  • 45
  • 63
0

ASP .NET MVC was built with the Model-View-Controller (MVC) pattern in mind. That would be the pattern you'd want to use.

In addition to the resources magnifico provided, I know others have recommended the some other tutorials. I don't know if these have been updated to the latest version of the framework, but they should still serve as decent beginners.

MVC Storefront series

MVC Music Store

Also the Microsoft Patterns & Practices group recently released Project Silk which gets into more advanced techniques involving a lot of AJAX management of the UI. There's interesting stuff there.

Hc5kphUXpR
  • 155
  • 1
  • 8