Ok, i’ve been learning MVC now for 2 days, but I still can’t wrap my head around it. ASP.NET MVC feels like learning Mandrin Chinese. So, I understand Classic ASP.NET and using an N-Tier archetucture, but how would you apply that to MVC? I comprehend View (the UI), Controller (the pipeline to the Model and View), and the Model (where your code goes), but how would you apply an N-tier to MVC? Or, a replica of the DAL? Yeah, it might be a stupid question, but I am not understanding the Framework. Does anyone have an article(s) that cleared your understanding of MVC? Maybe I need to buy a book…
Here is a good article about using MVC with N-tier architecture:
http://www.mikesdotnetting.com/Article/132/ASP.NET-MVC-is-not-all-about-Linq-to-SQL
Thanks for the insite guys, I appreciate it. Serena, I will take you up on your offer when I get my specs completed. Thanks for the help.
Patriot, I get frustrated quickly myself, but two days is a little short, even for me.
Do you have an existing N-Tier app already developed that you plan on migrating over to MVC? If so, a great deal of your work is already done.
A typical MVC based solution will have several projects in it.
eStore.Domain - the entities (classes to be mapped to some storage medium) and repository interfaces
eStore.Persistence - the repository implementations
eStore.Infrastructure - base classes and other common abstracts
eStore.ApplicationServices - things like EmailService and MetricsService
eStore.Resources - xml, res, and anything else you’ll need
eStore.Web - the MVC facade.
Having said that, the MVC project itself has three main areas, Controllers, Models, and Views. The only thing that would go in your Models folder is what we call a ViewModel (unlike the samples at asp.net/mvc which tend to toss everything into models).
If you have an existing app and just need to change the facade, then you have a ton of options open to you. For example, if you already have some old DCOM type components up and running within MTS, or some web services already up on some machine, you can consume those in your mvc controllers instead. You still have access to Server.CreateObject in your mvc controllers.
So honestly, the MVC project is just a facade for your apps. You are free to consume whatever technology you want with it, however you want.
Hope that helps.
I’d just generally note that MVC is really a UI pardagim. The N-tier bits really sit behind the controllers, who’s responsibility is to talk to the back-end services (N-tier bits) and give the right stuff to the view.