introduction to asp.net 5 and mvc 6 - files.meetup.com file•windows-only server that allows...

69
Introduction to ASP.NET 5 and MVC 6

Upload: others

Post on 31-Aug-2019

19 views

Category:

Documents


0 download

TRANSCRIPT

Page 1: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Introduction to ASP.NET 5 and MVC 6

Page 2: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Ovais Mehboob Ahmed Khan

MICROSOFT MVP Visual Studio and Development Technologies

DZone MVB

@ovaismehboobReach me at:

[email protected]

Page 3: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

History of ASP.NET

• 2002 – ASP.NET

• 2008 – ASP.NET MVC

• 2010 – ASP.NET Web Pages

• 2012 – ASP.NET Web API, Signal R

• 2015 – ASP.NET 5

Page 4: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

What’s come in .NET 2015

Page 5: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows
Page 6: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows
Page 7: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows
Page 8: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

.NET Core

Page 9: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

.NET Core

Page 10: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

.NET Core •

Page 11: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

.NET Core Major Components• Two Major Components

• Core CLR • Built on the same codebase as the .NET Framework CLR.

• Includes the same GC and JIT (RyuJIT)

• Does not include features like Application Domains or Code Access Security.

• The runtime is delivered on NuGet (Microsoft.CoreCLR package)

• .NET Core Foundation Libraries (CoreFX)• Are the same code as the .NET Framework class libraries but does not contain

dependencies so have a smaller footprint.

• Available on NuGet (System.* package)

Page 12: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Core CLR

Page 13: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows
Page 14: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

ASP.NET Transition

Page 15: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

ASP.NET 5 and the Modern Web

Page 16: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Modern Web – Agility

Page 17: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Modern Web - Fast

Page 18: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Modern Web – Cloud

Page 19: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Modern Web – Cross Platform

Page 20: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

DemoExplore VS 2015 project templates

Create ASP.NET Web Application

Discuss ASP.NET 5 Environment Files

Page 21: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Command Line Tools

- DNX (.NET Execution)- New execution environment of .NET- DNX bootstraps and runs your application- Not the CLR only, contains CoreFX as well- Install using DNVM

- DNVM (.NET Version Manager)- Set of command line utilities to update and configure which .NET Runtime to use- Downloadable from aspnet/home GitHub repository

- DNU (.NET Utility)- .NET Utility used to perform tasks like building, installing packages etc

Page 22: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

DNX

Page 23: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Getting DNX

Page 24: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

DNX

Page 25: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

DNX

Page 26: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

DNX

Page 27: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Running DNX

Page 28: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

DNU

Page 29: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

ASP.NET 5

Page 30: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Servers

• IIS and WebListener is for Windows only

• Kestrel is designed to run Cross Platform

Page 31: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Windows based Servers

• IIS and IIS Express• Hosting ASP.NET 5 on IIS bypasses the legacy System.Web infrastructure and

load pipeline defined in Startup.cs

• WebListener• Windows-only server that allows ASP.NET to be hosted outside IIS,

• Runs directly on Http.Sys kernel driver of windows

• It provides same features interface as IIS

• You can think it as a library version of IIS

Page 32: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Cross Platform Server

• Kestrel• Web server based on libuv

• Libuv – cross platform asynchronous I/O library

• Kestrel is open source

• View on github

• https://github.com/aspnet/KestrelHttpServer

Page 33: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

ASP.NET 5 invoked

Page 34: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Pipeline primitives

Page 35: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Dependency Injection

Page 36: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Registering Dependencies

Page 37: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Dependency Resolution

ASP.NET 5 depends on many packages

How the CLR Load the assemblies?

Two rules for loading Dependencies

- Nearest wins

- Cousin dependencies

Page 38: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Application using Nearest Wins

- Nearest-Wins allows a package/application to override any particular version of a package in its dependency tree by directly depending on the version it wants.

Page 39: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Package using Nearest Wins

Page 40: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Configuration

Page 41: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Configuration Example

Page 42: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows
Page 43: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Packaging & Publishing

Page 44: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

MVC 6

Page 45: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Packaging

Page 46: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Middleware

Page 47: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Routing

Page 48: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Controller

Page 49: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Attribute Routing

Page 50: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Combining Routing Parameters

Page 51: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Route Parameters

Page 52: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

HTTP Based Routes

Page 53: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Areas

Page 54: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

POCO Controllers

Page 55: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Dependency Injection

Page 56: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Model Binding Changes

Page 57: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Razor Directives

Page 58: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

@inject

Page 59: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Tag Helpers

Page 60: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Tag Helpers

Page 61: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Tag Helper Implementation

Page 62: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

MVC Tag Helpers

Page 63: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Validation Tag Helpers

Page 64: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Publishing

Page 65: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Publishing

Page 66: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Publishing

Page 67: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Publishing

Page 68: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Deploying to IIS

• Point it to the wwwroot folder of published content

Page 69: Introduction to ASP.NET 5 and MVC 6 - files.meetup.com file•Windows-only server that allows ASP.NET to be hosted outside IIS, •Runs directly on Http.Sys kernel driver of windows

Thank YouTwitter: @OvaisMehboob

Email: [email protected]