190 likes | 216 Vues
Transitioning to ASP.NET Core. It Doesn’t Have to Hurt. About Your Speaker. Mitchel Sellers Microsoft MVP & ASPInsider CEO @ IowaComputerGurus, Inc. Contact Information msellers@iowacomputergurus.com Twitter: @ MitchelSellers Blog: http://www.mitchelsellers.com. Agenda.
E N D
Transitioning to ASP.NET Core It Doesn’t Have to Hurt
About Your Speaker • Mitchel Sellers • Microsoft MVP & ASPInsider • CEO @ IowaComputerGurus, Inc. • Contact Information • msellers@iowacomputergurus.com • Twitter: @MitchelSellers • Blog: http://www.mitchelsellers.com
Agenda • Audience Overview? • What is ASP.NET Core? • What does ASP.NET Core get me? • Limitations? Restrictions? • Making the Transision? • Decision Points?
Quick Survey • Current ASP.NET Web Forms Users? • Current ASP.NET MVC Users? • Current .NET Core Users?
What is ASP.NET MVC Core? • Open-Source • Cross Platform (Windows, Linux, Mac) • Web Server Agnostic • Re-write from ground up • Modular In Nature vs. Old style • Multiple NuGet Packages vs System.Web.dll • Moves substantially faster than everything in the past
Why Would I Benefit? • A unified story for building web UI and web APIs • Integration of modern client-side frameworks and development workflows • A cloud-ready environment-based configuration system • Built-in dependency injection • New light-weight and modular HTTP request pipeline • Ability to host on IIS or self-host in your own process • Built on .NET Core, which supports true side-by-side app versioning • Ships entirely as NuGet packages • New tooling that simplifies modern web development • Build and run cross-platform ASP.NET apps on Windows, Mac and Linux • Open source and community focused (Taken from ASP.NET Core Documentation)
But really? What does it get ME?? • Side-by-side deployment possibilities • No longer concerned about “is the server patched” • Does introduce new “is my app patched” question • Better runtime experience • In VS, when not attached to the debugger can get realtime changes • Streamlined syntax requiring less work (TagHelpers) • <a asp-controller=“Home” asp-action=“Index”>Home</a> • Dependency Injection • Logging
Understanding .NET Core Support Policy • Looking back: .NET Framework • Framework patching done with OS • .NET 4.6 for example is good until 2029 • .NET Core: Introduces two tracks… • LTS (Long Term Support) • 3 Years after initial date released (* 1.x is different) • Current • 3 Months after subsequent LTS or Current release • .NET Core (3.0 – The good version) • NOT LTS!
But I Migrate to What? • Versions have created confusion • Version 1.0 -> 1.1 is a migration • Version 1.1 -> 2.0 is a migration • Version 2.0 -> 2.1 is much easier • Version 2.1 -> 2.2 Isn’t Horrible • Version 2.2 -> 3.0 is a migration * • Starting? Start newest, but consider upgrade path
How to Migrate? • No automatic process • Documentation: https://docs.asp.net/en/latest/migration/index.html • Basic minimums involve many manual migration steps • Initial Steps • Create a new Core Project to go alongside • Perform mandatory changes along the way • Ensure Developer Errors Enabled: app.UseDeveloperExceptionPage();
View Changes Required • Mandatory • @Script.Render => <script src=“”></script> • @Styles.Render => <link href=“”/> • Optional • Change to using TagHelpers to get rid of @Html.ActionLink etc. • Use of new <environment> tag for script differences <environment names="Development"> <link rel="stylesheet" href="~/css/backend.min.css"/> </environment> <environment names="Staging,Production"> <link rel="stylesheet" href="~/css/backend.min.css" asp-append-version="true"/> @Html.Raw(aiJavascriptSnippet.FullScript) </environment>
Client File, Bundling & Configuraton • Static files must be moved to the new /wwwroot folder • Bundling must be reconfigured to use the new “BundlerMinifier.Core” process • I find this process much nicer • Web.config is no longer used, application.json is now used • Changes to use IOptions for dependency injection
Migration of Identity & EF • Configuration moves to a new location • Dependency Injection now used to validate things such as role membership etc • Best Recommendation: Replace existing Login and associated views based on the new examples from a sample project
HttpHandlers & HttpModules • Don’t exist anymore, replaced with “Middleware” • More simple, but need to be re-implemented
Realistic Project Example – FlightFiles.com • Existing ASP.NET MVC Project • Started at MVC 3 using WebMatrix User accounts • About 1,500 hours of development total • 13 Controllers, 55 Views, 1 large data loader • Migrated to ASP.NET Core 1.1 • Transitioned to full .NET Core • Transitioned to using Identity for authentication • Total cost about 140 man-hours • Result? • Performance benchmarks improved by 61% across the app • Specific data queries as much as 500 times faster • Migration to Core 2.0 was estimated at 8 hours • Migrated to ASP.NET Core 2.0 • Total cost of about 12 man-hours • Performance improved again by about 15%
Decision Point? • What now? • Which support branch can we use? • LTS – Might have limited features • Current – Better features, but less stable and more updates • New Projects • Ideally currently, Use Current but be aware. My $0.02 • Existing Projects • Decision time?
Understanding the Decision • With it being a re-write – Ask yourself if it is truly necessary. • .NET Framework is supported for the foreseeable future • Can this be paired with other work? Possibly part of an overhaul • Don’t upgrade just to upgrade, at this point • Be sure to educate others on what this means to support, versioning, and upgrades.
Quick Project Overview • Questions?