ASP.NET MVC Presentation

20,887 views

Published on

ASP.NET MVC Presentation

Published in: Technology
3 Comments
7 Likes
Statistics
Notes
No Downloads
Views
Total views
20,887
On SlideShare
0
From Embeds
0
Number of Embeds
243
Actions
Shares
0
Downloads
1,331
Comments
3
Likes
7
Embeds 0
No embeds

No notes for slide

ASP.NET MVC Presentation

  1. 1. ASP.NET MVC M odel V iew C ontroller (MVC) applications by using the ASP.NET framework Ivan Polyakov Developer at Wildbit www.wildbit.com
  2. 2. What is ASP.NET MVC? <ul><li>Saying simply, ASP.NET MVC is a new framework from Microsoft that sits over standard ASP.NET engine. </li></ul>ASP.NET ASP.NET MVC
  3. 3. ASP.NET MVC Features <ul><li>What new does ASP.NET MVC bring in terms of web architecture? </li></ul>1. Clear separation of logic: Model, View, Controller 2. Test-Driven Development 3. Full control over HTML and JavaScript 4. Friendly URLs
  4. 4. M odel + V iew + C ontroller = MVC <ul><li>ASP.NET MVC provides an alternative to the ASP.NET “Web Forms” pattern for creating MVC-based Web applications. </li></ul>Model Controller View Model objects implement the logic for the application's data domain. Often, model objects retrieve and store the app state in a database. Controllers handle user interaction, work with the model, and select a view to render that displays UI Views display the application's user interface (UI). Typically, this UI is created from the model data.
  5. 5. Test-Driven Development <ul><li>Since the UI is completely separated from the business logic, it’s now easy to write Unit Tests for the ASP.NET MVC application. </li></ul>Controller Unit Tests that cover User Actions and Data Model User Interface Data Objects
  6. 6. Full control over HTML & JS <ul><li>In ASP.NET MVC, designed HTML & JS pages are not more messed up with “postbacks” and “ViewStates”, which is specific for “Web-forms” pattern. </li></ul><input type=&quot;hidden&quot; name=&quot;__VIEWSTATE&quot; id=&quot;__VIEWSTATE&quot; value=&quot;/wEPaA8FDzhjYjBhZjA0ODYyMTM2NBgGBR5fX0NvbnRyb2xzUmVxdWlyZVBvc3RCYWNrS2V5X18WAQUhY3RsMDAkaGVhZGVyJHVjTWFpbk1lbnUkc2VhcmNoQnRuBTdjdGwwMCRNYWluQ29udGVudCRycHRWaWRlbyRjdGwwMyRwcmVzZW50YXRpb25DYXJkJG11bHRp&quot; /> <script type=&quot;text/javascript&quot;> //<![CDATA[ var theForm = document.forms['aspnetForm']; function __doPostBack(eventTarget, eventArgument) { if (!theForm.onsubmit || (theForm.onsubmit() != false)) { theForm.__EVENTTARGET.value = eventTarget; theForm.__EVENTARGUMENT.value = eventArgument; theForm.submit(); } } //]]> </script>
  7. 7. Friendly URLs <ul><li>MVC binds web paths to the logical URLs rather than to the physical files. </li></ul>C:InetpubwwwrootWebSiteProducts.aspx http://www.website.com/Products.aspx?name=Meat http://www.website.com/Products/Meat Physical location: ASP.NET style: MVC style:
  8. 8. How does ASP.NET MVC looks like? <ul><li>ASP.NET MVC installs a new type of web project into VS2008. </li></ul>
  9. 9. How does ASP.NET MVC looks like? <ul><li>A newly created project has an ASP.NET MVC specific directory structure. </li></ul>App_Data folder is the physical store for data. Content folder keeps files such as scripts, CSS, images, and so on. Controllers folder is the location for controllers. The MVC framework requires the names of all controllers to end with &quot;Controller&quot;—for example, HomeController, LoginController, or ProductController. Models stores classes that handle application business logic. Scripts folder is for script files that support the application. By default, this folder contains AJAX script files and the JQuery library. Views is the recommended location for views. Views use .aspx, .ascx, and .master files, in addition to any other files that are related to rendering views.
  10. 10. Conclusion <ul><li>ASP.NET MVC supports pure MVC pattern, the same development pattern Rails are based on. The advantages of ASP.NET MVC applications: </li></ul><ul><li>It makes it easier to manage complexity by dividing an application into the model, the view, and the controller. </li></ul><ul><li>It does not use view state or server-based forms. </li></ul><ul><li>It uses a Front Controller pattern that processes Web application requests through a single controller. This enables you to design an application that supports a rich routing infrastructure with friendly URLs . </li></ul><ul><li>It provides better support for test-driven development (TDD). </li></ul><ul><li>It works well for Web applications that are supported by large teams of developers and Web designers who need a high degree of control over the application behavior. </li></ul>
  11. 11. Web Links to Additional Resources <ul><li>http://www.asp.net/mvc - official site </li></ul><ul><li>http://weblogs.asp.net/scottgu/archive/2007/11/13/asp-net-mvc-framework-part-1.aspx - development basics on ASP.NET MVC </li></ul><ul><li>http://weblogs.asp.net/scottgu/archive/2007/12/03/asp-net-mvc-framework-part-2-url-routing.aspx - URL routing used in ASP.NET MVC </li></ul><ul><li>http://weblogs.asp.net/scottgu/archive/2007/12/06/asp-net-mvc-framework-part-3-passing-viewdata-from-controllers-to-views.aspx - interaction between Controllers and Views </li></ul><ul><li>http://weblogs.asp.net/scottgu/archive/2007/12/09/asp-net-mvc-framework-part-4-handling-form-edit-and-post-scenarios.aspx - managing form input data </li></ul>

×