Introduction to ASP NET MVC Chapter 1 ASP

  • Slides: 14
Download presentation
Introduction to ASP. NET MVC Chapter 1 ASP. NET MVC Development

Introduction to ASP. NET MVC Chapter 1 ASP. NET MVC Development

Contents 1. The case for ASP. NET MVC 2. Tooling up 2

Contents 1. The case for ASP. NET MVC 2. Tooling up 2

1. The Case for ASP. NET MVC n What is ASP. NET MVC? n

1. The Case for ASP. NET MVC n What is ASP. NET MVC? n ASP. NET Web Forms – issues n Web development – state of play n ASP. NET MVC architecture n ASP. NET MVC benefits n ASP. NET Web Forms or MVC? 3

What is ASP. NET MVC? n ASP. NET MVC is a web development platform

What is ASP. NET MVC? n ASP. NET MVC is a web development platform from Microsoft • n A significant evolution for web developers using the Microsoft platform ASP. NET MVC emphasises the best of the ASP. NET platform and agile development: Clean architecture • Design patterns • Testability • 4

ASP. NET Web Forms – Issues n Traditional ASP. NET Web Forms were a

ASP. NET Web Forms – Issues n Traditional ASP. NET Web Forms were a great step forward when they first emerged Much better than classic Active Server Pages (ASP) • Simple, especially for relatively small applications • n However, there are some significant issues with ASP. NET Web Forms • • • View. State transmission can be onerous The ASP. NET page life cycle is complicated and subtle The ASP. NET code-behind model encourages developers to mix presentation logic and application logic Web Forms attempt to encapsulate the intricacies of HTML and HTTP, but this can sometimes be an obstacle It's difficult to automate unit testing for ASP. NET Web Forms 5

Web Development – State of Play n Key features of Web development today: Ajax

Web Development – State of Play n Key features of Web development today: Ajax • Web standards • REST (Representational State Transfer) • Agile and test-driven development • 6

ASP. NET MVC Architecture HTTP Request Controller Response HTML n View Model View data

ASP. NET MVC Architecture HTTP Request Controller Response HTML n View Model View data The controller is probably the most interesting player • Processes user input n • Manages application logic n • Works with the model to handle the request E. g. navigating a multi-step process, authentication, etc. Prepares the data to be displayed n This is known as "view data" in ASP. NET MVC 7

ASP. NET MVC Benefits n Here are the key benefits of ASP. NET MVC:

ASP. NET MVC Benefits n Here are the key benefits of ASP. NET MVC: • • Model-View-Controller architecture Extensibility (ASP. NET MVC components are pluggable) Reusable and consistent model classes Testability Flexible routing system Tight control over HTML (standards-compliant) Leverages strengths of the ASP. NET platform Simplified Java. Script/Ajax integration 8

ASP. NET Web Forms or MVC? n ASP. NET Web Forms is still appropriate

ASP. NET Web Forms or MVC? n ASP. NET Web Forms is still appropriate for: • Small Web applications n • Simple Intranet-style Web applications n • n Maybe you don't really care about unit testing or long-term maintenance Web apps where you have a lot of corporate data n • Fast networks, so you don't care about View. State transmission overheads Quick-to-market apps n • MVC would be overkill Where you just want to display the data in data grids Scenarios where the drag-and-drop simplicity of Web Forms outweighs its weaknesses A word about migration… You can mix ASP. NET Web. Forms and MVC in the same Web app • Allows you to migrate Web. Forms to MVC piecemeal, if you want to • 9

2. Tooling Up n Core development tools n MVC 4 n Downloading and installing

2. Tooling Up n Core development tools n MVC 4 n Downloading and installing MVC 4 10

Core Development Tools n The following tools include ASP. NET MVC by default: Visual

Core Development Tools n The following tools include ASP. NET MVC by default: Visual Studio 2010 (any edition) • Visual Web Developer 2010 Express (free) • n The following tools don't include ASP. NET MVC by default (you must download ASP. NET MVC separately from http: //www. asp. net/mvc/) Visual Studio 2008 with SP 1 (any edition) • Visual Web Developer 2008 Express with SP 1 (free) • 11

MVC 4 n ASP. NET MVC 4 builds on ASP. NET MVC 1, 2,

MVC 4 n ASP. NET MVC 4 builds on ASP. NET MVC 1, 2, and 3 Adds features to simplify code and support deeper extensibility • Installs side-by-side with ASP. NET MVC 2 • n Key new features: • • • Expressive views, including the new Razor view engine Internet and Intranet project templates HTML 5 support Extensible scaffolding with Mvc. Scaffold integration Hooks for Dependency Injection and global action filters Java. Script and Ajax improvements Model validation improvements Controller improvements Page caching and data caching 12

Downloading and Installing MVC 4 n Download available from MVC 4 home page •

Downloading and Installing MVC 4 n Download available from MVC 4 home page • n We'll install via installer executable • n http: //www. asp. net/mvc 4 C: Asp. Net. Mvc 4ProductsAsp. Net. MVC 4 Tools. Update. Setup. exe Effect: Adds new ASP. NET MVC 4 project templates • Extends existing APIs, adds new APIs • 13

Summary n The case for ASP. NET MVC n Tooling up 14

Summary n The case for ASP. NET MVC n Tooling up 14