Introducing asp net mvc 3
This presentation is the property of its rightful owner.
Sponsored Links
1 / 35

Introducing ASP.NET MVC 3 PowerPoint PPT Presentation


  • 107 Views
  • Uploaded on
  • Presentation posted in: General

Introducing ASP.NET MVC 3. Ori Calvo, 2010 Hi-Tech College [email protected] “If people want to have maximum reach across * all * devices then HTML will provide the broadest reach” Scott Guthrie, Corporate Vice President , Microsoft. Objectives. ASP.NET MVC Basics

Download Presentation

Introducing ASP.NET MVC 3

An Image/Link below is provided (as is) to download presentation

Download Policy: Content on the Website is provided to you AS IS for your information and personal use and may not be sold / licensed / shared on other websites without getting consent from its author.While downloading, if for some reason you are not able to download a presentation, the publisher may have deleted the file from their server.


- - - - - - - - - - - - - - - - - - - - - - - - - - E N D - - - - - - - - - - - - - - - - - - - - - - - - - -

Presentation Transcript


Introducing asp net mvc 3

Introducing ASP.NET MVC 3

Ori Calvo, 2010

Hi-Tech College

[email protected]


Introducing asp net mvc 3

“If people want to have maximum reach across *all* devices then HTML will provide the broadest reach”

Scott Guthrie, Corporate Vice President, Microsoft


Objectives

Objectives

  • ASP.NET MVC Basics

  • What’s new in ASP.NET MVC 3

  • Summary


Prerequisites

Prerequisites

  • ASP.NET Developer

  • Good understanding of HTML and HTTP

  • Good understanding of C# 3.0 Language

  • No ASP.NET MVC Experience is required


Part 1 asp net mvc basics

Part 1ASP.NET MVC Basics


Quick demo

Quick Demo

  • Create new ASP.NET MVC Project

  • Create new controller

  • Create new View


Classical asp net

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 !!!


What s wrong with it

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


Asp net mvc

ASP.NET MVC

  • Separation of concerns

  • Tight control over HTML

  • Designed to be testable

  • Extensible routing system

  • Better integration with 3rd party libraries

  • Open source

  • Built on top of ASP.NET platform

  • Language innovations


Software requirements

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


Web platform installer

Web Platform Installer


Mvc ingredients

MVC Ingredients

  • Routing System

  • Controller

  • Action

  • Filter

  • View

  • Model

  • Model State

  • View Bag


Demo real life controller

Demo – Real life controller

  • GroupController

  • Index View

  • Click a group

  • Back to parent


Demo extending views

Demo – Extending Views

  • Partial View - Menu

  • Layouts - Header and footer

  • Sections – Add “scripts” section


Demo submitting data

Demo – Submitting Data

  • Create new group

  • Method selector

  • Automatic model binding

  • Validation

  • DataAnnotations

  • Edit a group

  • TryUpdateModel

  • jQuery to set focus


Demo controlling access

Demo – Controlling Access

  • Authorize filter

  • FormsAuthentication

  • LoginDetails as ViewModel


Demo routing system

Demo – Routing System

  • Simplifying URLs

  • Implement “CMS like” URLs


Part 2 what s new in asp net mvc 3

Part 2What’s new in ASP.NET MVC 3?


What s new

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)


Razor

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


Razor syntax

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 <text>

  • Use @* and *@ for comments

  • Use @functions to add some functions

  • Use @inherits to specify different base class


Demo razor

Demo - Razor

  • Resolve ambiguities

  • Create a unit test

  • Write inline template


Nuget

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?


Nuget1

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


Nuget algorithm

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


Demo nuget

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


Iis express

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


Demo iis express

Demo - IIS Express

  • Changing VS to work with IIS Express

  • Change VS default

  • Execute under Integrated Mode

  • Change application pool using AppCmd.exe


Demo ef code first

Demo – EF Code First

  • Use DbContext

  • Change the database name

  • Use SQL CE

  • Dispose the context

  • Use validation


What s new in asp net mvc 3

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


Asp net mvc vs asp net web forms

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 …)


Summary

Summary

  • A different way to develop web applications

  • Razor Syntax – Clear & easier to maintain

  • NuGet – Integrate 3rd party libraries

  • IIS Express – IIS for the developer

  • Better Validation – Based on jQuery and Unobtrusive JavaScript principles

  • Many small enhancements


Questions

TryUpdateModel

Questions ?


Read more

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/


Thank you

Thank You !!!


  • Login