asp.net core changes every developer should know

35
ASP.NET Core MVC Changes Every Developer Should Know

Upload: ed-charbeneau

Post on 14-Apr-2017

271 views

Category:

Technology


3 download

TRANSCRIPT

Page 1: ASP.NET Core Changes Every Developer Should Know

ASP.NET Core MVCChanges Every Developer Should Know

Page 2: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.2

About Me

Ed Charbeneau Developer Advocate for Progress, Telerik DevCraft Developer.Telerik.com Twitter @EdCharbeneau

Page 3: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.3

.NET Core overview

Page 4: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.4

Hello.NET Core 1.1.1

Cross platform• Development,

Deployment• Windows, Mac, Linux

Current App Models• UWP• Console Applications• ASP.NET Core

Page 5: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.5

Hello ASP.NET Core 1.1.1

vNext ASP.NET 5 ASP.NET Core 1.1.1

Page 6: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.6

Cross platform development

DOTNET CLI

Read more: http://developer.telerik.com/featured/net-cli-decoded/

Page 7: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.7

Cross platform deployment

Page 8: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.8

ASP.NET Core “MVC” overview

Page 9: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.9

Just the FAQs

ASP.NET Core is a complete rewrite MVC is a module for ASP.NET Core MVC and Web API have merged into a single codebase There is no longer an MVC 6, the module was reversioned to 1.0 There is no official plan for WebForms on .NET Core

Page 10: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.10

Modularity

ASP.NET Core uses a request pipeline Successor to HttpHandler Read / Write directly to the HTTP Pipeline

using middleware MVC is ASP.NET Core middleware Raw access to the HTTP request/response

(A.k.a. the bare metal) Built using Dependency Injection

Pipeline

HTTP Request

HTTP Response

middleware

MVC

middleware

Page 11: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.11

No dependency on IIS

Remember, cross platform! ASP.NET Core can be:

• Self-hosted• Cloud hosted• Mac, Windows, Linux• Docker (integrated with VS2017)

Page 12: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.12

cross-platform asynchronous I/O library

Should use Reverse Proxy Server

ASP.NET Core Module .UseIISIntegration()

Servers

Kestrel WebListener

Windows only Direct connection to the Internet

Page 13: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.13

File, New Project

Page 14: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.14

What's (Mostly) the Same

MVC design pattern itself• Models• Views • Controller

Page 15: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.15

What's Missing

App_Start App_Data Global.ASAX /Scripts /Content Web.Config*

* For IIS support only

Page 16: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.16

ASP.NET Core 1.0 – 1.1 changes

/src Project.json

• In ASP.NET Core 1.0, this replaced .csproj• .csproj is back in 1.1• 1.0 apps must to migrate to .csproj

Web.Config• For IIS support only

Page 17: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.17

What’s new

/wwwroot Dependencies /Data/Migrations Appsettings.json Startup.cs Program.cs _ViewImports.cshtml

Page 18: ASP.NET Core Changes Every Developer Should Know

Visual Studio Demo

Page 19: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.19

Application Initialization

Page 20: ASP.NET Core Changes Every Developer Should Know

ASP.NET Core is a Console Application

Page 21: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.21

Application Initialization

ASP.NET Core

No dependency on IIS Initialized via command line Program.Main() builds web host &

invokes Startup Startup.cs handles startup

.NET Framework 4.6, ASP.NET

IIS (InetMgr.exe) initialized application HttpApplication.Application_Start() Startup code handled by Global.asax

Page 22: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.22

Application Startup

Replaces App_Start, and Global.ASAX Startup is called by WebHostBuilder.UseStartup

Program.Main()

ConfigureServices()

Configure()

Startup

Startup()

Page 23: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.23

New Configuration Options

Configuration options are resolved in the Startup constructor Settings can be stored in .json, .xml or environment variables

Page 24: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.24

Overloading Configuration Options

Overloading

Dev Ops Friendly Multiple configs

• Development• Staging• Production

Last setting to be resolved wins

Example

var builder = new ConfigurationBuilder() .SetBasePath(env.ContentRootPath) .AddJsonFile(“foo.json”) .AddJsonFile(“bar.json”);

Configuration.GetValue<string>(“myKey”); //=> Bar

Page 25: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.25

Startup methods

ConfigureServices

Dependency Injection (DI) configured IServiceCollection is the DI container AddTransient<TService, TImplementation>();

services.AddMvc();

Configure

HTTP Middleware is added IApplicationBuilder is the pipeline app.UseMiddleware() app.UseMvc(routes …)

Page 26: ASP.NET Core Changes Every Developer Should Know

Visual Studio Demo

Page 27: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.27

TagHelpers

Page 28: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.28

Overview

Augments HTML to include server-side code & values

Page 29: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.29

Just the FAQs

TagHelpers Are

Use tags and attributes like HTML Rendered Server-Side Supported by intellisense

TagHelpers Are Not

Going to eliminate Razor @Html Like WebForms

Page 30: ASP.NET Core Changes Every Developer Should Know

Visual Studio Demo

Page 31: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.31

Page 32: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.32

UI for ASP.NET Core

For ASP.NET Core 70+ ASP.NET MVC Components Powered by Kendo UI Charts Graphs Grids Schedulers Responsive, works on any screen size

Page 33: ASP.NET Core Changes Every Developer Should Know

© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.33

Polished UI for All your Appshttp://telerik.com/devcraft

Page 34: ASP.NET Core Changes Every Developer Should Know

Thank you

Page 35: ASP.NET Core Changes Every Developer Should Know