Successfully reported this slideshow.
We use your LinkedIn profile and activity data to personalize ads and to show you more relevant ads. You can change your ad preferences anytime.

Getting Started with ASP.NET MVC


Published on

This is an introductory session that will give you an overview of mvc. We'll examine some of the basic principles behind the framework and contrast it with webforms. The session will cover topics such as model binding, routing and rad development using mvc.

Published in: Technology
  • Be the first to comment

Getting Started with ASP.NET MVC

  1. 1. Getting Started with ASP.NET MVC <br />
  2. 2. Housekeeping<br />Stuttering is a communication disorder involving disruptions, or “disfluencies,” in a person’s speech.<br />Across all cultures, roughly 1% of people currently has a stuttering disorder.<br /><br />
  3. 3. HattanShobokshi<br />Senior Software Engineer<br /><br /><br /><br />Who am I?<br />
  4. 4. Goals for this talk<br /> Present an overview of ASP.NET MVC<br />MVC vsWebforms. Why?<br />What is the MVC paradigm?<br />Controllers and Action Methods<br />Views<br />Html Helpers<br />Models<br />Model Binding<br />Routing<br />Best Practices<br />
  5. 5. A new web development framework that allows you to develop web applications on the Microsoft stack using an MVC Architecture.<br />Is NOT a replacement for traditional ASP.NET web forms.<br />Web Forms vs MVC<br />Current Version is MVC3.<br />MVC2 and MVC3 are extension of MVC1.<br />MVC1 and MVC2 - .NET Framework 3.5 & 4.0<br />MVC3 4.0 ONLY<br />Visual Studio Tooling Support<br />Convention over configuration<br />What is ASP.NET MVC<br />
  6. 6. What is MVC?<br />
  7. 7.
  8. 8. Why should I use ASP.NET MVC? <br />Testability<br />Model Binder is awesome!<br />No Viewstate<br />SEO friendly url’s<br />Complete control over Html output<br />Easier integration with Jquery<br />Better Separation of Concerns<br />
  9. 9. ASP.NET Web Forms<br />Traditional url<br />
  10. 10. ASP.NET MVC<br /><br />Admin is not a folder, but a class called AdminController<br />Menu is not a file, but a Method in the AdminController Class<br />
  11. 11. DEMO<br />
  12. 12. Routing<br />Route engine parses url’s, extracts any data and sends it off to controller<br />Create extremely customizable routes<br />Route table defines routes in global.asax<br />You do not need to define a route to handle querystring parameters. They are automatically mapped.<br />
  13. 13. Model <br />The model is the representation of your data.<br />Business Logic<br />
  14. 14. Views<br />No Code behind<br />Action methods by default call views with the same name. (Convention over configuration)<br />Views are not tied to a specific action method or controller.<br />Views should be dumb (shouldn’t contain any application logic, only rendering logic)<br />Views can be strongly typed<br />
  15. 15. Html Helpers<br />Html helpers are extension methods that generate html. @Html.TextBox(“Name”,”Bob”)<br />Html helpers are NOT controls, they simply generate html markup (strings)<br />You can create your own Html Helper.<br />
  16. 16. Model Binding<br />Takes data from an html form and creates an object.<br />No need to write plumbing code <br />
  17. 17. Best Practices<br />Never include a hard reference in the view(eg <script src=“../js/jquery.js”></script>)instead use url.content like so<script src=“<%=Url.Content(“~/js/jquery.js”)%>”></script>)<br />Never have big if then else in view, put it in an html helper<br />Add namespace to web.config so you don’t have to keep referencing it on each page<br />The difference between routing name and class name. <br />
  18. 18. Where can I get it?<br /><br /><br />
  19. 19. Resources<br /><br /><br />Pro ASP.NET MVC Framework by Steven Sanderson<br /> mvc Forums<br /><br />
  20. 20. What did we just talk about?<br /> Present an overview of ASP.NET MVC<br /> MVC vsWebforms. Why?<br />What is the MVC paradigm?<br />Controllers and Action Methods<br />Views<br />Html Helpers<br />Models<br />Model Binding<br />Routing<br />Best Practices<br />
  21. 21. The End<br />Thank you!<br />