Getting Started with ASP.NET MVC
-
Upload
shobokshi -
Category
Technology
-
view
1.557 -
download
3
description
Transcript of Getting Started with ASP.NET MVC
Getting Started with ASP.NET
MVC
Housekeeping
*Stuttering is a communication disorder involving disruptions, or “disfluencies,” in a person’s speech.
*Across all cultures, roughly 1% of people currently has a stuttering disorder.
*http://westutter.org/
Goals for this talk
* Present an overview of ASP.NET MVC
* MVC vs Webforms. Why?
*What is the MVC paradigm?
*Controllers and Action Methods
*Views
*Html Helpers
*Models
*Model Binding
*Routing
*Best Practices
* A new web development framework that allows you to develop web applications on the Microsoft stack using an MVC Architecture.
* Is NOT a replacement for traditional ASP.NET web forms.
* Web Forms vs MVC
* Current Version is MVC3.
* MVC2 and MVC3 are extension of MVC1.
* MVC1 and MVC2 - .NET Framework 3.5 & 4.0
* MVC3 4.0 ONLY
* Visual Studio Tooling Support
* Convention over configuration
What is ASP.NET
MVC
*What is MVC?
Why should I use ASP.NET MVC?
*Testability
*Model Binder is awesome!
*No Viewstate
*SEO friendly url’s
*Complete control over Html output
*Easier integration with Jquery
*Better Separation of Concerns
*ASP.NET Web Forms
*Traditional urlhttp://www.yoursite.com/admin/menu.aspx
*ASP.NET MVC
*http://www.yoursite.com/admin/menu
*Admin is not a folder, but a class called AdminController
*Menu is not a file, but a Method in the AdminController Class
*DEMO
*Routing
*Route engine parses url’s, extracts any data and sends it off to controller
*Create extremely customizable routes
*Route table defines routes in global.asax
*You do not need to define a route to handle querystring parameters. They are automatically mapped.
*Model
*The model is the representation of your data.
*Business Logic
*Views
*No Code behind
*Action methods by default call views with the same name. (Convention over configuration)
*Views are not tied to a specific action method or controller.
*Views should be dumb (shouldn’t contain any application logic, only rendering logic)
*Views can be strongly typed
*Html Helpers
*Html helpers are extension methods that generate html. @Html.TextBox(“Name”,”Bob”)
*Html helpers are NOT controls, they simply generate html markup (strings)
*You can create your own Html Helper.
*Model Binding
*Takes data from an html form and creates an object.
*No need to write plumbing code
*Best Practices
*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>)
*Never have big if then else in view, put it in an html helper
*Add namespace to web.config so you don’t have to keep referencing it on each page
* The difference between routing name and class name.
Where can I get it?
http://www.asp.net/mvc/download/
http://www.microsoft.com/express/Web/
Resources
*http://www.asp.net/learn/mvc/
*http://www.asp.net/learn/mvc-videos/
*Pro ASP.NET MVC Framework by Steven Sanderson
*Asp.net mvc Forumshttp://forums.asp.net/1146.aspx
*http://haacked.com/
What did we just talk about?
* Present an overview of ASP.NET MVC
* MVC vs Webforms. Why?
*What is the MVC paradigm?
*Controllers and Action Methods
*Views
*Html Helpers
*Models
*Model Binding
*Routing
*Best Practices
The End
Thank you!