Create an account


Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
ASP.NET Core updates in .NET Core 3.0 Preview 5

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

<div style="margin: 5px 5% 10px 5%;"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2019/05/asp-net-core-updates-in-net-core-3-0-preview-5.jpg" width="58" height="58" title="" alt="" /></div><div><div class="row justify-content-center">
<div class="col-md-4">
<div><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/05/asp-net-core-updates-in-net-core-3-0-preview-5.jpg" width="58" height="58" alt="Avatar" class="avatar avatar-58 wp-user-avatar wp-user-avatar-58 photo avatar-default"></div>
</div>
</div>
<div class="entry-meta">
<p>May 6th, 2019</p>
</p></div>
<p><!-- .entry-meta --> </p>
<p><a href="https://devblogs.microsoft.com/dotnet/announcing-net-core-3-0-preview-5/">.NET Core 3.0 Preview 5 is now available</a>. This iteration was brief for the team and primarily includes bug fixes and improvements to the more significant updates in <a href="https://devblogs.microsoft.com/aspnet/asp-net-core-updates-in-net-core-3-0-preview-4/">Preview 4</a>. This post summarizes the important points in this release.</p>
<p>Please see the <a href="http://aka.ms/netcore3releasenotes">release notes</a> for additional details and known issues.</p>
<h2>Get started</h2>
<p>To get started with ASP.NET Core in .NET Core 3.0 Preview 5 <a href="https://dot.net/get-core3">install the .NET Core 3.0 Preview 5 SDK</a>. If you’re on Windows using Visual Studio, you also need to <a href="https://visualstudio.com/preview">install the latest preview of Visual Studio</a>.</p>
<h2>Upgrade an existing project</h2>
<p>To upgrade an existing an ASP.NET Core app (including Blazor apps) to .NET Core 3.0 Preview 5, follow the <a href="https://docs.microsoft.com/en-us/aspnet/core/migration/22-to-30">migrations steps in the ASP.NET Core docs</a>. Please also see the full list of <a href="https://github.com/aspnet/announcements/issues?utf8=%E2%9C%93&amp;q=is%3Aissue+label%3A3.0.0+label%3A%22Breaking+change%22">breaking changes</a> in ASP.NET Core 3.0.</p>
<p>To upgrade an existing ASP.NET Core 3.0 Preview 4 project to Preview 5:</p>
<ul>
<li>Update Microsoft.AspNetCore.* package references to 3.0.0-preview5-19227-01</li>
<li>Update Microsoft.Extensions.* package references to 3.0.0-preview5.19227.01</li>
</ul>
<p>That’s it! You should be good to go with this latest preview release.</p>
<h2>New JSON Serialization</h2>
<p>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.</p>
<p>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:</p>
<pre><code class="diff">public void ConfigureServices(IServiceCollection services)
{ ... services.AddControllers() .AddNewtonsoftJson() ...
}</code></pre>
<p>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 <a href="https://github.com/aspnet/AspNetCore/issues/new/choose">here</a>.</p>
<p>We used this WeatherForecast model when we profiled JSON read/writer performance using Newtonsoft.Json, our previous serializer.</p>
<pre><code class="csharp">public class WeatherForecast
{ public DateTime Date { get; set; } public int TemperatureC { get; set; } public string Summary { get; set; }
}</code></pre>
<h3>JSON deserialization (input)</h3>
<table>
<thead>
<tr>
<th>Description</th>
<th>RPS</th>
<th>CPU (%)</th>
<th>Memory (MB)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Newtonsoft.Json – 500 bytes</td>
<td>136,435</td>
<td>95</td>
<td>172</td>
</tr>
<tr>
<td>System.Text.Json – 500 bytes</td>
<td>167,861</td>
<td>94</td>
<td>169</td>
</tr>
<tr>
<td>Newtonsoft.Json – 2.4 kbytes</td>
<td>97,137</td>
<td>97</td>
<td>174</td>
</tr>
<tr>
<td>System.Text.Json – 2.4 kbytes</td>
<td>132,026</td>
<td>96</td>
<td>169</td>
</tr>
<tr>
<td>Newtonsoft.Json – 40 kbytes</td>
<td>7,712</td>
<td>88</td>
<td>212</td>
</tr>
<tr>
<td>System.Text.Json – 40 kbytes</td>
<td>16,625</td>
<td>96</td>
<td>193</td>
</tr>
</tbody>
</table>
<h3>JSON serialization (output)</h3>
<table>
<thead>
<tr>
<th>Description</th>
<th>RPS</th>
<th>CPU (%)</th>
<th>Memory (MB)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Newtonsoft.Json – 500 bytes</td>
<td>120,273</td>
<td>94</td>
<td>174</td>
</tr>
<tr>
<td>System.Text.Json – 500 bytes</td>
<td>145,631</td>
<td>94</td>
<td>173</td>
</tr>
<tr>
<td>Newtonsoft.Json – 8 Kbytes</td>
<td>35,408</td>
<td>98</td>
<td>187</td>
</tr>
<tr>
<td>System.Text.Json – 8 Kbytes</td>
<td>56,424</td>
<td>97</td>
<td>184</td>
</tr>
<tr>
<td>Newtonsoft.Json – 40 Kbytes</td>
<td>8,416</td>
<td>99</td>
<td>202</td>
</tr>
<tr>
<td>System.Text.Json – 40 Kbytes</td>
<td>14,848</td>
<td>98</td>
<td>197</td>
</tr>
</tbody>
</table>
<p>For the most common payload sizes, System.Text.Json offers about 20% throughput increase during input and output formatting with a smaller memory footprint.</p>
<p>Options for the serializer can be configured using <code>MvcOptions</code>:</p>
<pre><code class="csharp">services.AddControllers(options =&gt; options.SerializerOptions.WriteIndented = true) </code></pre>
<h3>Integration with SignalR</h3>
<p>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.</p>
<h3>Switching back to Newtonsoft.Json</h3>
<p>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.</p>
<ol>
<li>Install the <code>Microsoft.AspNetCore.SignalR.Protocols.NewtonsoftJson</code> NuGet package.</li>
<li>
<p>On the client add <code>.AddNewtonsoftJsonProtocol()</code> to the <code>HubConnectionBuilder</code>:</p>
<pre><code class="csharp">new HubConnectionBuilder()
.WithUrl("/chatHub")
.AddNewtonsoftJsonProtocol()
.Build();</code></pre>
</li>
<li>
<p>On the server add <code>.AddNewtonsoftJsonProtocol()</code> to the <code>AddSignalR()</code> call:</p>
<pre><code class="csharp">services.AddSignalR()
.AddNewtonsoftJsonProtocol();</code></pre>
</li>
</ol>
<h2>Give feedback</h2>
<p>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 <a href="https://github.com/aspnet/aspnetcore/issues">Github</a>.</p>
<div class="authorinfoarea">
<div><img src="http://www.sickgaming.net/blog/wp-content/uploads/2019/05/asp-net-core-updates-in-net-core-3-0-preview-5-1.jpg" width="96" height="96" alt="Avatar" class="avatar avatar-96 wp-user-avatar wp-user-avatar-96 photo avatar-default"></div>
<div>
<h5><a class="no-underline" aria-label=" Brady Gaster" target="_blank" href="https://devblogs.microsoft.com/aspnet/author/bradygmicrosoft-com/" rel="noopener noreferrer"> Brady Gaster</a></h5>
<p>Senior Program Manager,&nbsp;ASP.NET Core</p>
<p><strong>Follow </strong>&nbsp;&nbsp;&nbsp;<a class="no-underline stayinformed" aria-label=" Brady Gaster Twitter profile" target="_blank" href="https://twitter.com/bradygaster" rel="noopener noreferrer"><i class="fa fa-twitter"></i></a><a class="no-underline stayinformed" aria-label=" Brady Gaster GitHub profile" target="_blank" href="https://github.com/bradygaster" rel="noopener noreferrer"><i class="fa fa-github"></i></a><a class="no-underline stayinformed hvr-pop" aria-label=" Brady Gaster RSS Feed" target="_blank" href="https://devblogs.microsoft.com/aspnet/author/bradygmicrosoft-com/feed/" rel="noopener noreferrer"></a></p>
</p></div>
</p></div>
</div>
Reply



Forum Jump:


Users browsing this thread:
1 Guest(s)

Forum software by © MyBB Theme © iAndrew 2016