All new stuff in ASP.NET Core 2.0

ASP.Net core 2.0 is just around the corner and all the good stuff is on the way, let’s look at some of those:

Razor Pages

With ASP.NET Core 2.0, Microsoft introduced the “Razor Pages” as a new development model, competing with the previous Model View Controller approach. The tools and documentation made it clear that Microsoft favors this new model. In ASP.NET Core 2.1, therefore, most of the new features refer to the Razor Pages. These should now be packaged for reuse in several projects in DLLs. The Razor Pages, which have been translated at runtime, now translate to development time. Microsoft is the first UI package to offer authentication and user management capabilities to make it easier to integrate these features into any ASP.NET core web application.

Areas

With “Areas”, developers can organizationally separate the pages within a project. Each area can have its own “/ shared” directory. Microsoft simplifies data binding in Razor Pages by applying the annotation [BindPropertyAttribute] centrally to a class. With the IPageFilter interface, developers can run logic before and after the Razor Page Handler. But also for MVC-based pages, there are improvements through a new tag helper to include page fragments as well as the new helper class WebApplicationTestFixture for writing unit tests.

ApiController

For ASP.NET Core based Web APIs, Microsoft offers more parameter binding and validation automation with the [ApiController] annotation. The new class ActionResult <T> improves the generation of Swagger OpenAPI documentation so that swagger annotations are no longer necessary in many situations. In addition, Microsoft now supports the transmission of problem details according to RFC 7808. Also, the port of WebHooks and SignalR frameworks for push messages from the web server to the client wants to complete Microsoft to version 2.1 of ASP.NET Core.

HttpClientFactory

With the new HttpClientFactory , Microsoft simplifies the handling of timeouts, retries, and caching. In ASP.NET Core 1.0, Microsoft had decided to run the program code no longer as before in ASP.NET in the process of the web server Internet Information Services (IIS), but as a separate process (“Kestrel”). Microsoft has revised this decision in version 2.1, increasing its throughput by six times.

[Route("api/[controller]")]
public class ValuesController : Controller
{
    private readonly IHttpClientFactory _httpClientFactory;

    public ValuesController(IHttpClientFactory httpClientFactory)
    {
        _httpClientFactory = httpClientFactory;
    }

    [HttpGet]
    public async Task<ActionResult> Get()
    {
        var client = _httpClientFactory.CreateClient();
        var result = await client.GetStringAsync("http://www.yourservice.com");
        return Ok(result);
    }
}

 

The project templates of ASP.NET will in future use the standard HTTPS. Likewise, project templates will ask the user for their consent to the use of cookies in accordance with the EU’s General Data Protection Regulation (GDPR).

You may also like...

Leave a Reply

Your email address will not be published.