Presentation is loading. Please wait.

Presentation is loading. Please wait.

Ori Calvo, 2010 Hi-Tech College

Similar presentations


Presentation on theme: "Ori Calvo, 2010 Hi-Tech College"— Presentation transcript:

1 Ori Calvo, 2010 Hi-Tech College Ori.calvo@gmail.com

2 “If people want to have maximum reach across *all* devices then HTML will provide the broadest reach” Scott Guthrie, Corporate Vice President, MicrosoftCorporate Vice President

3 Objectives ASP.NET MVC Basics What’s new in ASP.NET MVC 3 Summary

4 Prerequisites ASP.NET Developer Good understanding of HTML and HTTP Good understanding of C# 3.0 Language No ASP.NET MVC Experience is required

5

6 Quick Demo Create new ASP.NET MVC Project Create new controller Create new View

7 Classical ASP.NET Huge shift at that time Object oriented approach Compiled web pages Stateful UI Event Driven Drag and Drop Designer Windows Forms Developing Experience Is here to stay !!!

8 What’s wrong with it? Is “Windows Forms” approach suited? Limited control over HTML Encourages mixing of presentation and logic Hard to test ViewState Complex page life cycle Hard to integrate with other libraries

9 ASP.NET MVC Separation of concerns Tight control over HTML Designed to be testable Extensible routing system Better integration with 3 rd party libraries Open source Built on top of ASP.NET platform Language innovations

10 Software Requirements.NET Framework 4.0 Visual Studio 2010 Visual Web Developer 2010 Can be installed into the bin directory In case the Web Host does not support it directly Installation can be automated by Web Platform Installer Additional components can be installed using NuGet

11 Web Platform Installer

12 MVC Ingredients Routing System Controller Action Filter View Model Model State View Bag

13 Demo – Real life controller GroupController Index View Click a group Back to parent

14 Demo – Extending Views Partial View - Menu Layouts - Header and footer Sections – Add “scripts” section

15 Demo – Submitting Data Create new group Method selector Automatic model binding Validation DataAnnotations Edit a group TryUpdateModel jQuery to set focus

16 Demo – Controlling Access Authorize filter FormsAuthentication LoginDetails as ViewModel

17 Demo – Routing System Simplifying URLs Implement “CMS like” URLs

18

19 What’s new? ASP.NET MVC 3 NuGet 1.1 IIS Express 7.5 SQL Server Compact Edition 4.0 Web Deploy and Web Farm Framework 2.0 Orchard 1.0 Web Matrix 1.0 Entity Framework Code First (CTP5)

20 Razor Just another View Engine Better integration of C# and HTML Is focused around the @ character No need to set the end of code Is testable Is extendible Follows the same compilation model as ASPX Can be compiled at design time

21 Razor syntax Use @ to move between code and HTML Use @() to specify long expression Use @{} to run arbitrary code which doesn’t writes into the response stream Use @: inside code region to move back to HTML Can also use Use @* and *@ for comments Use @functions to add some functions Use @inherits to specify different base class

22 Demo - Razor Resolve ambiguities Create a unit test Write inline template

23 NuGet Consider following scenario You want to install a library named X X has a dependency on Y You also want to install library named Z Z has a dependency on Y Need to think about: Where can you get latest of all libraries? What are the dependencies of each library? Is it ok to use the latest release for Y? If not, what happens if Z depends on a different version of Y than X?

24 NuGet A library package manager Deals with packages rather than assemblies An extension to Visual Studio 2010 Not just for ASP.NET MVC projects Packages come from a well known repository Automatically handling of version conflicts and updates Once package is imported NuGet stays out of the way No integration with TFS

25 NuGet Algorithm Never installs assemblies at machine level Uses bin deploy Prefers unification over “side by side” Always picks the lowest version of a dependency that fits in the range Always move up to the highest build/revision Can use the Add-BindingRedirect power shell command

26 Demo - NuGet Install T4MVC Install NHibernate Handle conflicts Get a list of updates available Create a local repository Give a look at http://nuget.org

27 IIS Express Quick installation (less than 10MB) Better support for IIS feature set SSL Integrated Mode URL Re-Writing Same configuration schema Does not require administrator privileges Doesn’t run as a service Can co-exist with full IIS7.x and Cassini Works on Windows XP SP3 and later Supports multiple users on the same machine Supports WCF but only over HTTP Integrated into Visual Studio 2010 SP1 beta

28 Demo - IIS Express Changing VS to work with IIS Express Change VS default Execute under Integrated Mode Change application pool using AppCmd.exe

29 Demo – EF Code First Use DbContext Change the database name Use SQL CE Dispose the context Use validation

30 What’s new in ASP.NET MVC 3? Unobtrusive JavaScript Posting JSON objects Class level model validation Partial page output caching Better Dependency Injection ViewBag Global Filters Sessionless Controller

31 ASP.NET MVC vs. ASP.NET Web Forms Both based on ASP.NET infrastructure Same objectives, different ways Both server centric How sophisticated the UI need to be? Are you planning for automation coverage? What is your team developing background? Can mix both in the same project You can use ASP.NET Server Controls inside views (don’t tell anybody …)

32 Summary A different way to develop web applications Razor Syntax – Clear & easier to maintain NuGet – Integrate 3 rd party libraries IIS Express – IIS for the developer Better Validation – Based on jQuery and Unobtrusive JavaScript principles Many small enhancements

33 Questions ? TryUpdateModel

34 Read more Course 4282 at Hi-Tech College (Next Week!!!) http://weblogs.asp.net/scottgu/ http://www.hanselman.com/blog/ http://www.asp.net/mvc http://jquery.com/

35 Thank You !!!


Download ppt "Ori Calvo, 2010 Hi-Tech College"

Similar presentations


Ads by Google