The document provides an overview of changes for developers moving to ASP.NET Core 1 from MVC and Web API. Key changes include ASP.NET Core 1 being cross-platform and lightweight, unifying MVC and Web API concepts, and reworking low-level APIs. The middleware pipeline is configured to route requests and add services. Tag helpers replace HTML helpers for view rendering. Web APIs use attribute routing but no longer have conventions for HTTP verbs; the WebApiCompatShim can be added to support conventions.
1. 1
ASP.NET Core 1 (formerly ASP.NET 5)
What has changed for MVC and Web API devs?
Manfred Steyer
ManfredSteyer
About me …
Manfred Steyer
SOFTWAREarchitekt.at
Trainer & Consultant
Angular
Server-Side .NET
Page 2
2. 2
Goal
Overview of changes for
MVC- and Web API-Devs regarding
ASP.NET Core
Folie 3
Didactics
Slides
Samples
Folie 9
6. 6
System.Web
Features of System.Web have to be
reimplemented
Sessions, Caching, Configuration, Routing
Consequence: Breaking-Changes
Folie 30
Doublings today
Web API MVC Web Pages
7. 7
ASP.NET MVC Core 1
Unification of MVC, Web API
and (in future) Web Pages
Uniform concepts for Controllers, Views,
Dependency-Injection, Routing, Filters etc.
Migration
Code needs adaptation
But: Current framework-versions will be maintained
Saying that: WCF and Web Forms wont't be
migrated to Core
WCF Web Forms Web API 2MVC 5
.NET 4.x / "Full CLR"
13. 13
WEB APIS WITH MVC CORE 1
Page 50
Web APIs in MVC Core 1
No own Routing for Web APIs
Same concept as for MVC
No Conventions for HTTP Verb,
like GetAll() GET, PostData() POST
Routing doesn't consider URL-Parameters to select
an action-method
But: WebApiCompatShim
Folie 51
14. 14
Web API with Attribute-based Routes
Folie 52
[Route("api/[controller]")]
public class FlightController: Controller
{
[HttpGet("{id}")]
public Flight GetById(int id) { […] }
[HttpGet("byRoute")]
public List<Flight> GetByRoute(string from, string to) { […] }
[HttpPost]
public void PostFlight([FromBody] Flight flight) { […] }
}
Web API with Attribute-based Routes
Folie 53
[Route("api/[controller]")]
public class FlightController: Controller
{
// GET api/flight/{id}
[HttpGet("{id}")]
public Flight GetById(int id) { […] }
[HttpGet("byRoute")]
public List<Flight> GetByRoute(string from, string to) { […] }
[HttpPost]
public void PostFlight([FromBody] Flight flight) { […] }
}
15. 15
Web API with Attribute-based Routes
Folie 54
[Route("api/[controller]")]
public class FlightController: Controller
{
// GET api/flight/{id}
[HttpGet("{id}")]
public Flight GetById(int id) { […] }
// GET api/flight/byRoute?from=...&to=...
[HttpGet("byRoute")]
public List<Flight> GetByRoute(string from, string to) { […] }
[HttpPost]
public void PostFlight([FromBody] Flight flight) { […] }
}
Web API with Attribute-based Routes
Folie 55
[Route("api/[controller]")]
public class FlightController: Controller
{
// GET api/flight/{id}
[HttpGet("{id}")]
public Flight GetById(int id) { […] }
// GET api/flight/byRoute?from=...&to=...
[HttpGet("byRoute")]
public List<Flight> GetByRoute(string from, string to) { […] }
// POST api/flight
[HttpPost]
public void PostFlight([FromBody] Flight flight) { […] }
}
16. 16
DEMO
Page 56
Configuring MVC and Formatters
Folie 57
public class Startup
{
public void ConfigureServices(IServiceCollection services)
{
services.AddMvc()
.AddJsonOptions(options => { […] })
.AddMvcOptions(options => { […] });
}
[…]
}
18. 18
Summary
Folie 80
X-Plattform F5-Compile Side-by-Side
Self-Hosting
DI, DI
everywhere…
Tag Helpers
Summary
Folie 81
Unification
of MVC and
Web API
High-Level-
APIs quite
the same
MVC-Style
Routing
Low-Level
APIs
reworked
Current
versions still
maintained