ASP.NET Core updates in .NET Core 3.0 Preview 5

Avatar

ASP.NET Core updates in .NET Core 3.0 Preview 5

.NET Core 3.0 Preview 5 is now available. This iteration was brief for the team and primarily includes bug fixes and improvements to the more significant updates in Preview 4. This post summarizes the important points in this release.

Please see the release notes for additional details and known issues.

Get started

To get started with ASP.NET Core in .NET Core 3.0 Preview 5 install the .NET Core 3.0 Preview 5 SDK. If you’re on Windows using Visual Studio, you also need to install the latest preview of Visual Studio.

Upgrade an existing project

To upgrade an existing an ASP.NET Core app (including Blazor apps) to .NET Core 3.0 Preview 5, follow the migrations steps in the ASP.NET Core docs. Please also see the full list of breaking changes in ASP.NET Core 3.0.

To upgrade an existing ASP.NET Core 3.0 Preview 4 project to Preview 5:

  • Update Microsoft.AspNetCore.* package references to 3.0.0-preview5-19227-01
  • Update Microsoft.Extensions.* package references to 3.0.0-preview5.19227.01

That’s it! You should be good to go with this latest preview release.

New JSON Serialization

In 3.0-preview5, ASP.NET Core MVC adds supports for reading and writing JSON using System.Text.Json. The System.Text.Json serializer can read and write JSON asynchronously, and is optimized for UTF-8 text making it ideal for REST APIs and backend applications.

This is available for you to try out in Preview 5, but is not yet the default in the templates. You can use the new serializer by removing the call to add Newtonsoft.Json formatters:

public void ConfigureServices(IServiceCollection services)
{
    ...
    services.AddControllers()
           .AddNewtonsoftJson()
    ...
}

In the future this will be default for all new ASP.NET Core applications. We hope that you will try it in these earlier previews and log any issues you find here.

We used this WeatherForecast model when we profiled JSON read/writer performance using Newtonsoft.Json, our previous serializer.

public class WeatherForecast
{
    public DateTime Date { get; set; }

    public int TemperatureC { get; set; }

    public string Summary { get; set; }
}

JSON deserialization (input)

Description RPS CPU (%) Memory (MB)
Newtonsoft.Json – 500 bytes 136,435 95 172
System.Text.Json – 500 bytes 167,861 94 169
Newtonsoft.Json – 2.4 kbytes 97,137 97 174
System.Text.Json – 2.4 kbytes 132,026 96 169
Newtonsoft.Json – 40 kbytes 7,712 88 212
System.Text.Json – 40 kbytes 16,625 96 193

JSON serialization (output)

Description RPS CPU (%) Memory (MB)
Newtonsoft.Json – 500 bytes 120,273 94 174
System.Text.Json – 500 bytes 145,631 94 173
Newtonsoft.Json – 8 Kbytes 35,408 98 187
System.Text.Json – 8 Kbytes 56,424 97 184
Newtonsoft.Json – 40 Kbytes 8,416 99 202
System.Text.Json – 40 Kbytes 14,848 98 197

For the most common payload sizes, System.Text.Json offers about 20% throughput increase during input and output formatting with a smaller memory footprint.

Options for the serializer can be configured using MvcOptions:

services.AddControllers(options => options.SerializerOptions.WriteIndented = true) 

Integration with SignalR

System.Text.Json is now the default Hub Protocol used by SignalR clients and servers starting in ASP.NET Core 3.0-preview5. Please try it out and file issues if you find anything not working as expected.

Switching back to Newtonsoft.Json

If you would like to switch back to the previous default of using Newtonsoft.Json then you can do so on both the client and server.

  1. Install the Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson NuGet package.
  2. On the client add .AddNewtonsoftJsonProtocol() to the HubConnectionBuilder:

    new HubConnectionBuilder()
    .WithUrl("/chatHub")
    .AddNewtonsoftJsonProtocol()
    .Build();
  3. On the server add .AddNewtonsoftJsonProtocol() to the AddSignalR() call:

    services.AddSignalR()
    .AddNewtonsoftJsonProtocol();

Give feedback

We hope you enjoy the new features in this preview release of ASP.NET Core! Please let us know what you think by filing issues on Github.

Avatar
Brady Gaster

Senior Program Manager, ASP.NET Core

Follow    

23 Comments
Avatar
Juan Benjamín Camacho Castro 2019-05-06 09:25:22
Krzysztof Jeske
Krzysztof Jeske 2019-05-06 15:11:12
Shouldn't the Microsoft.Extensions.* package references be updated to 3.0.0-preview5.19227.9 ?
Ben Hayat
Ben Hayat 2019-05-06 20:15:41
Looks like Blazor SS will RTM end of Sept. as part of .Net Core 3.0. And 3.1 will RTM in Nov. I wonder if 3.1 will have the Blazor client side RTM?Then looking further ahead, in 2020 Nov. we will get the first version of .Net 5 which will be ONE .Net which runs everywhere. If the current MonoVM is so big for web assembly, how is .Net 5 going to fit in Web assebly as part of Blazor?If we write apps in Blazor, how will they load with .Net 5 into browser?Thanks!..Ben
Pavel Biryukov
Pavel Biryukov 2019-05-08 00:03:23
Is strict json validation supported?
Avatar
Carl Philipp Bickmeier 2019-05-09 04:22:39
Trying to update a Blazor-Server-Side-Project from preview 4 to preview 5... there are many changes that are not described here, bu I can compiled it now... but when I start the app does not come up. When I look into the html-code with dev tool I only see this: <app> <!-- M.A.C.Component:{"circuitId":"873bb404-0cef-463f-8046-e5e5c328e41d","rendererId":"0","componentId":"0"} --> <router appassembly="Diomex.XcalibuR.Configurator.Client.RazorComponents, Version=1.0.0.0, Culture=neutral, PublicKeyToken=null"></router> <!-- M.A.C.Component: 0 --> </app> What is missing here? Sime kind of not documented routing changes?
Avatar
SuperCocoLoco . 2019-05-10 03:38:14
Waiting for Visual Basic .NET support in ASP.NET Core.
Luke
Luke Grews 2019-05-15 19:48:24
Scaffolding is broken for .net core preview 5. 
Avatar
Manoj B. Kalla 2019-05-17 23:29:04
Brady Gaster Thank you sir for sharing new things JSON, Serialization and DeSerialization are important things nowadays
Roustan Thierry
Roustan Thierry 2019-05-24 02:20:56
Hi, Is it possible to have in razor page a navlink who link to an element of page ? ex: <div class="col-sm-1"><NavLink href="#bloc4">...</NavLink></div> ... <div class="row" id="bloc4">... it seems to be nor working :-( thanks
Randolph McClean
Randolph McClean 2019-05-26 12:32:59
Great article Brady, I was a bit confused on how to implement the new Json settings but you cleared that right up. Would this be the same when writing a Bazor application?
Avatar
anonymous 2019-05-27 20:24:47
This comment has been deleted.
Avatar
Sowmyan Soman Chullikkattil 2019-05-28 23:38:24
Is there a way to deploy the web apps built on 3.0, prev 5 in Azure for testing purpose ? looking for app service ? A supported docker image may work too i think.
Avatar
Sowmyan Soman Chullikkattil 2019-05-28 23:41:02
Is there a way to deploy the web apps built on 3.0, prev 5 in Azure for testing purpose ? looking for app service or a supported docker image may work too i think.
Avatar
mohammad ghorbani 2019-05-29 23:56:40
im translate some notes and two books about asp.net core to persian language , with this title اصول پایه ای asp.net core  در یک پروژه عملیyou can see it in my own blog , and purchase it to persian and iran . 
Avatar
Tristan Hen 2019-05-30 13:10:25
Does Azure Web App support this preview ?
Avatar
Stephen Buck 2019-06-05 08:32:02
Nice heads up on the changes.  Thx!
Avatar
Satva Solutions 2019-07-10 04:03:23
Good to know about ASP.NET Core MVC update. Thanks