asp.net core changes every developer should know
TRANSCRIPT
ASP.NET Core MVCChanges 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
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.3
.NET Core overview
© 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
© 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
© 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/
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.7
Cross platform deployment
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.8
ASP.NET Core “MVC” overview
© 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
© 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
© 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)
© 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
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.13
File, New Project
© 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
© 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
© 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
© 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
Visual Studio Demo
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.19
Application Initialization
ASP.NET Core is a Console Application
© 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
© 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()
© 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
© 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
© 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 …)
Visual Studio Demo
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.27
TagHelpers
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.28
Overview
Augments HTML to include server-side code & values
© 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
Visual Studio Demo
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.31
© 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
© 2016 Progress Software Corporation and/or its subsidiaries or affiliates. All rights reserved.33
Polished UI for All your Appshttp://telerik.com/devcraft
Thank you