The new and improved ASP .NET Core 2.1 introduces some great new capabilities, the ability to host on multiple server platforms, and a number of new tools that you will want to get familiar with. Learn about the future of ASP.NET Core MVC, Web API, Razor Web Pages, SignalR, .NET Core Tools and Visual Studio 2017!
25. MVC Models
using System.ComponentModel;
using System.ComponentModel.DataAnnotations;
public class Human
{
[Key]
public int Id { get; set; }
[DisplayName("First Name")]
public string FirstName { get; set; }
[DisplayName("First Name")]
public string LastName { get; set; }
}
29. SignalR in ASP.NET Core 2.1 (Stable!)
https://blogs.msdn.microsoft.com/webdev/2018/02/27/asp-net-core-2-1-0-preview1-getting-started-with-signalr
using Microsoft.AspNetCore.SignalR;
namespace SignalRTutorial.Hubs
{
[Authorize]
public class ChatHub : Hub
{
public override async Task OnConnectedAsync()
{
await Clients.All.SendAsync("SendAction", Context.User.Identity.Name, "joined");
}
public override async Task OnDisconnectedAsync(Exception ex)
{
await Clients.All.SendAsync("SendAction", Context.User.Identity.Name, "left");
}
public async Task Send(string message)
{
await Clients.All.SendAsync("SendMessage", Context.User.Identity.Name, message);
}
}
}
30. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
31. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• Real-time web development
• New Typescript client, jQuery
• Built-in Hub protocols:
• JSON-based for text
• MessagePack for binary
• Improved scale-out model
• Sticky sessions required*
*required when using WebSockets unless
skipNegotiation flag is set to true
var connection = new
signalR.HubConnectionBuilder().withUrl("/chat",
{
skipNegotiation: true,
transport: signalR.HttpTransportType.WebSockets
})
.build();
32. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• UseHttpsRedirection by default
• HSTS protocol support (non-dev)
• >dotnet dev-certs https --trust
33. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• New ApiController attribute
• Auto model validation
34. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• Rich Swagger support
• Easier API documentation
35. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• New type ActionResult<T>
• Indicate response type for any
action result
36. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• HttpClient as a service
• Register, configure, consume
HttpClient instances
37. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• ASP.NET Core (native IIS) Module
• Hooks into IIS pipeline
• Improved Performance
38. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• Default UI implemented in a library
• Available as NuGet package
• Enable via Startup class
39. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• Compliance for EU General Data
Protection Regulation reqts
• Request user consent for info
40. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• Mix authentication schemes
• e.g. Bearer tokens, cookie auth
41. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• Compiled during build process
• Improved startup performance
42. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• Razor UI as class library
• Share across projects
• Share as Nuget package
43. ASP.NET Core 2.1: What’s New?
http://www.talkingdotnet.com/quick-summary-whats-new-asp-net-core-2-1/
• Improved end-to-end testing
• e.g. routing, filters, controllers,
actions, views and pages
44. How about Entity Framework?
DB
ORM
Entities
in Code
Core
)
4.6+
4.6+
46. Pluralsight Course by Julie Lerman
https://app.pluralsight.com/library/courses/entity-framework-core-2-getting-started
54. ASP.NET Core Runtime Extension on Azure
https://blogs.msdn.microsoft.com/webdev/2018/02/27/asp-net-core-2-1-0-preview1-using-asp-net-core-previews-on-azure-app-service/
64. Migrating from MVC to MVC Core
https://docs.microsoft.com/en-us/aspnet/core/migration/mvc
65. dotnet/cli on GitHub
This repo
contains
the .NET
Core
command-
line (CLI)
tools, used
for
building
.NET Core
apps and
libraries.
GitHub: https://github.com/dotnet/cli
66. .NET Core 2.x CLI Commands
https://docs.microsoft.com/en-us/dotnet/core/tools/?tabs=netcore2x
>dotnet --version
>dotnet --info
>dotnet new <TEMPLATE> --auth <AUTH_TYPE> -o <OUTPUT_DIR>
>dotnet new console -o MyConsoleApp
>dotnet new mvc --auth Individual -o MyMvcWebApp
>dotnet restore
>dotnet build
>dotnet run
<TEMPLATE> = web | mvc | razor | angular | react | webapi
<AUTH_TYPE> for mvc,razor = None | Individual | SingleOrg | Windows
84. ASP.NET Core 2.1 Released
https://blogs.msdn.microsoft.com/dotnet/2018/05/30/announcing-net-core-2-1/
85. References
• ASP .NET: http://www.asp.net
• .NET Core: https://www.microsoft.com/net
• .NET Web Dev Blog: https://blogs.msdn.microsoft.com/webdev
• Scott Hanselman’s Blog: https://www.hanselman.com/blog
• .NET Conf: http://www.dotnetconf.net
• MSDN Channel 9: https://channel9.msdn.com
• Tutorials: https://docs.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app
• C# 7: https://docs.microsoft.com/en-us/dotnet/articles/csharp/csharp-7
• ASP.NET Core Roadmap: https://github.com/aspnet/Home/wiki/Roadmap
• .NET Core Roadmap: https://github.com/dotnet/core/blob/master/roadmap.md
86. Other Resources
• New Razor Pages: http://www.hishambinateya.com/welcome-razor-pages
• Intro to Razor: https://docs.microsoft.com/en-us/aspnet/core/mvc/razor-pages
• Live Unit Testing: https://blogs.msdn.microsoft.com/visualstudio/2016/11/18/live-
unit-testing-visual-studio-2017-rc
• Migrating from MVC to MVC Core: https://docs.microsoft.com/en-
us/aspnet/core/migration/mvc
• Visual Studio Code: https://code.visualstudio.com
• dotnet/cli on GitHub: https://github.com/dotnet/cli