ASP.NET Core updates in .NET Core 3.1 Preview 1 - Printable Version +- Sick Gaming (https://www.sickgaming.net) +-- Forum: Programming (https://www.sickgaming.net/forum-76.html) +--- Forum: C#, Visual Basic, & .Net Frameworks (https://www.sickgaming.net/forum-79.html) +--- Thread: ASP.NET Core updates in .NET Core 3.1 Preview 1 (/thread-92112.html) |
ASP.NET Core updates in .NET Core 3.1 Preview 1 - xSicKxBot - 10-23-2019 ASP.NET Core updates in .NET Core 3.1 Preview 1 <div style="margin: 5px 5% 10px 5%;"><img src="https://www.sickgaming.net/blog/wp-content/uploads/2019/10/asp-net-core-updates-in-net-core-3-1-preview-1.jpg" width="150" height="150" title="" alt="" /></div><div><div class="row justify-content-center"> <div class="col-md-4"> <div><img src="https://www.sickgaming.net/blog/wp-content/uploads/2019/10/asp-net-core-updates-in-net-core-3-1-preview-1.jpg" width="58" height="58" alt="Daniel Roth" class="avatar avatar-58 wp-user-avatar wp-user-avatar-58 alignnone photo"></p> <p>Daniel</p> </div> </div> </div> <div class="entry-meta"> <p>October 15th, 2019</p> </p></div> <p><!-- .entry-meta --> </p> <p><a href="https://devblogs.microsoft.com/dotnet/announcing-net-core-3-1-preview-1/">.NET Core 3.1 Preview 1 is now available</a>. This release is primarily focused on bug fixes, but it contains a few new features as well.</p> <p>Here’s what’s new in this release for ASP.NET Core:</p> <ul> <li>Partial class support for Razor components</li> <li>Pass parameters to top-level components</li> <li>Support for shared queues in HttpSysServer</li> <li>Breaking changes for SameSite cookies</li> </ul> <p>Alongside this .NET Core 3.1 Preview 1 release, we’ve also released a Blazor WebAssembly update, which now requires .NET Core 3.1. To use Blazor WebAssembly you will need to install .NET Core 3.1 Preview 1 as well as the latest preview of Visual Studio.</p> <p>See the <a href="https://github.com/dotnet/core/blob/master/release-notes/3.1">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.1 Preview 1 <a href="https://dotnet.microsoft.com/download/dotnet-core/3.1">install the .NET Core 3.1 Preview 1 SDK</a>.</p> <p>If you’re on Windows using Visual Studio, for the best experience we recommend <a href="https://visualstudio.com/preview">installing the latest preview of Visual Studio 2019 16.4</a>. Installing Visual Studio 2019 16.4 will also install .NET Core 3.1 Preview 1, so you don’t need to separately install it. For Blazor development with .NET Core 3.1, Visual Studio 2019 16.4 is <em>required</em>.</p> <p>To install the latest Blazor WebAssembly template run the following command:</p> <pre><code>dotnet new -i Microsoft.AspNetCore.Blazor.Templates::3.1.0-preview1.19508.20 </code></pre> <h2>Upgrade an existing project</h2> <p>To upgrade an existing ASP.NET Core 3.0 project to 3.1 Preview 1:</p> <ul> <li>Update any projects targeting netcoreapp3.0 to target netcoreapp3.1</li> <li>Update all Microsoft.AspNetCore.* package references to 3.1.0-preview1.19506.1</li> </ul> <p>See also the full list of <a href="https://github.com/aspnet/announcements/issues?utf8=%E2%9C%93&q=is%3Aissue+label%3A3.1.0+label%3A%22Breaking+change%22">breaking changes</a> in ASP.NET Core 3.1.</p> <p>That’s it! You should now be all set to use .NET Core 3.1 Preview 1!</p> <h2>Partial class support for Razor components</h2> <p>Razor components are now generated as partial classes. You can author the code for a Razor component using a code-behind file defined as a partial class instead of defining all the code for the component in a single file.</p> <p>For example, instead of defining the default <code>Counter</code> component with an <code>@code</code> block, like this:</p> <p><em>Counter.razor</em></p> <pre><code class="razor">@page "/counter" <h1>Counter</h1> <p>Current count: @currentCount</p> <button class="btn btn-primary" @onclick="IncrementCount">Click me</button> @code { int currentCount = 0; void IncrementCount() { currentCount++; } } </code></pre> <p>You can now separate out the code into a code-behind file using a partial class like this:</p> <p><em>Counter.razor</em></p> <pre><code class="razor">@page "/counter" <h1>Counter</h1> <p>Current count: @currentCount</p> <button class="btn btn-primary" @onclick="IncrementCount">Click me</button> </code></pre> <p><em>Counter.razor.cs</em></p> <pre><code class="csharp">namespace BlazorApp1.Pages { public partial class Counter { int currentCount = 0; void IncrementCount() { currentCount++; } } } </code></pre> <h2>Pass parameters to top-level components</h2> <p>Blazor Server apps can now pass parameters to top-level components during the initial render. Previously you could only pass parameters to a top-level component with <code>RenderMode.Static</code>. With this release, both <code>RenderMode.Server</code> and <code>RenderModel.ServerPrerendered</code> are now supported. Any specified parameter values are serialized as JSON and included in the initial response.</p> <p>For example, you could prerender a <code>Counter</code> component with a specific current count like this:</p> <pre><code class="csharp">@(await Html.RenderComponentAsync<Counter>(RenderMode.ServerPrerendered, new { CurrentCount = 123 })) </code></pre> <h2>Support for shared queues in HttpSysServer</h2> <p>In addition to the existing behavior where HttpSysServer created anonymous request queues, we’ve added to ability to create or attach to an existing named HTTP.sys request queue.<br />This should enable scenarios where the HTTP.Sys controller process that owns the queue is independent to the listener process making it possible to preserve existing connections and enqueued requests between across listener process restarts.</p> <pre><code class="csharp">public static IHostBuilder CreateHostBuilder(string[] args) => Host.CreateDefaultBuilder(args) .ConfigureWebHostDefaults(webBuilder => { // ... webBuilder.UseHttpSys(options => { options.RequestQueueName = "MyExistingQueue", options.RequestQueueMode = RequestQueueMode.CreateOrAttach }) }); </code></pre> <h2>Breaking changes for SameSite cookies</h2> <p>This release updates the behavior of SameSite cookies in ASP.NET Core to conform to the latest standards being enforced by browsers. For details on these changes and their impact on existing apps see https://github.com/aspnet/Announcements/issues/390.</p> <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> <p>Thanks for trying out ASP.NET Core!</p> <div class="authorinfoarea"> <div><img src="https://www.sickgaming.net/blog/wp-content/uploads/2019/10/asp-net-core-updates-in-net-core-3-1-preview-1.jpg" width="96" height="96" alt="Daniel Roth" class="avatar avatar-96 wp-user-avatar wp-user-avatar-96 alignnone photo"></div> <div> <h5><a class="no-underline" aria-label="Daniel Roth" href="https://devblogs.microsoft.com/aspnet/author/danroth27/">Daniel Roth</a></h5> <p>Principal Program Manager, ASP.NET</p> <p><strong>Follow Daniel</strong> <a class="no-underline stayinformed" aria-label="Daniel Roth Twitter profile" target="_blank" href="https://twitter.com/danroth27" rel="noopener noreferrer"><i class="fa fa-twitter"></i></a><a class="no-underline stayinformed" aria-label="Daniel Roth GitHub profile" target="_blank" href="https://github.com/danroth27" rel="noopener noreferrer"><i class="fa fa-github"></i></a><a class="no-underline stayinformed hvr-pop" aria-label="Daniel Roth RSS Feed" target="_blank" href="https://devblogs.microsoft.com/aspnet/author/danroth27/feed/" rel="noopener noreferrer"></a></p> </p></div> </p></div> </div> https://www.sickgaming.net/blog/2019/10/15/asp-net-core-updates-in-net-core-3-1-preview-1/ |