5. MVC Pattern - A Conceptual View Decouples the backend business logic from the front end Model Binds the model and view together and selects which view to display next Data Transfer Request Controller Business InteractionLayer User InteractionLayer View Response Visualizes the application data supplied by the model
6. Model Has business/domain logic ASP.NET MVC doesn’t tell you what to use: LINQ to SQL nHiberate Entity Framework PLINQO Custom/POCO object rev 1.0/0111
7. View Should be “thin” and dumb No business logic Only Display logic / Transformation of data JavaScript is valid for client side - jQuery rev 1.0/0111
8. Controller Should also be "thin" Controller has "Actions" Requests always come through the controller Decides what data is needed Tells which View to render Tells the View what "Model" render rev 1.0/0111
9. rev 1.0/0111 Agenda The MVC Pattern ASP.NET MVC 3 Getting Started with Razor Demos
10. What is ASP.NET MVC? ASP.NET MVC implements the Model-View-Controller pattern Provides an alternative to ASP.NET Web Forms Available from http://www.asp.net/mvc/mvc3 rev 1.0/0111 INTRODUCTION-10
19. ASP.NET MVC 3 Project Structure INTRODUCTION-13 Controllers Razor Pages (Views) Model Classes "Master Page" rev 1.0/0111
20. Steps to use ASP.NET MVC Create a controller class in the Controllers folder Add one or more Actions (methods) into the controller Right-click on an Action and select Add View from the menu rev 1.0/0111
21. rev 1.0/0111 Agenda The MVC Pattern ASP.NET MVC 3 Getting Started with Razor Demos
22. What is Razor? ASP.NET MVC 3 ships with a new View Engine called "Razor" Less markup transitions as compared to the ASP.NET Web Forms View Engine Provides a compact way to mingle code with markup Uses the @ character rev 1.0/0111
23. Without Razor <ul> <%foreach (varcust in Customers) { %> <li><%: cust.Name%></li> <% } %> </ul> rev 1.0/0111
24. With Razor <ul> @foreach (varcust in Customers) { <li>@cust.Name</li> } </ul> rev 1.0/0111
30. ASP.NET MVC 3 Demo Site Download an ASP.NET MVC 3 demo site from http://mvcmusicstore.codeplex.com rev 1.0/0111
31. Razor Tools Web Forms View to Razor View Converter:https://github.com/telerik/razor-converter MVC 2 to MVC 3 Project Converterhttp://aspnet.codeplex.com/releases/view/59008 rev 1.0/0111
Editor's Notes
There have been a lot of rumors floating around that ASP.NET Web Forms is dying and being replaced with ASP.NET MVC…you know, like the Web Forms Reaper is coming? Well….here I am!
It is up to you to decide how you want to get your data and how to define your objects. Although there are accepted guidelines on how to have good design, it is not decided for you with The ASP.Net MVC Framework.