Asp.net Core New Features

As we know Asp.Net Core is one of the most successful web development framework from Microsoft, has been very popular among web developers and software development companies for few very efficient and powerful new features of Asp.net Core.

asp.net core new features

Asp.net Framework is evolving year after year, in earlier asp.net framework we had few limitation from various aspect, but now Asp.net Core has been very different from earlier Asp.net Framework, even developer who has worked in earlier Asp.net version will find some Asp.net core features are completely new!

Main Features of Asp.net Core

  1. Multi-platform environment (Cross-platform) Support

    Now Asp.net is not limited to only windows, we can develop and deploy application for other operating systems like Linux, macOS too

    Now Asp.net Core application can be deployed using containers technologies like Docker, Kuberenetes etc. there is no need of having .net framework pre-installed in deployment environment (like earlier version of Asp.net) , now container will have all necessary assemblies, resources which is required to run the application.

  2. Asynchronous programming patterns (async/await)

    Asp.net core has introduced extensive use of asynchronous pattern, which make the application very faster and create best user experience, because async methods never blocks the UI for next action.

    public async Task<string> getwebcontent()
    {
        HttpClient hc=new HttpClient();
        string _responseresult;
        string _url="https://www.webtrainingroom.com";
        var _tmessage=await hc.GetAsync(_url);  
             
        _responseresult = await _tMessage.Content.ReadAsStringAsync();
        return _responseresult;
    }
    

    Take a look at the following examples to know more about Asynchronous programming in asp.net C#

  3. Middleware Service for Http Pipeline

    Now we can define how asp.net page request will process, the sequence of request in application, using middleware we can add anything to application pipeline.

    Middleware is an external component that is designed to form a pipeline between server and application; it allows manipulating the request for any particular application.

    In earlier Aps.net version the http request pipeline was fixed and predefined in asp.net framework, there was no option to alter the request pipeline, but in asp.net core that has been achieved with the help of middleware.

    Take a look at more details about Asp.net Core Middleware with examples

  4. appsettings.json instead of web.config

    Now in asp.net core there is no web.config file, instead we have appsettings.json file.

    Web.config was a xml file with some predefined framework configuration information, appsettings.json is a type of empty text file with .json extension, the file is empty, you need to define whatever configuration information you need, information needs to be in json format like example below.

    {
      "Logging": {
        "IncludeScopes": false,
        "LogLevel": {
          "Default": "Warning"
        }
      },
      "DbConnectionConfig": {
        "DatabaseName": "databaseName",
        "UserName": "dbUserName",
        "Password": "dbPassword",
        "ServerName": "DBServer\\SQLEXPRESS"
      }
    }
    

    Learn more about Appsettings.json configuration, reading values from appsettings and more.

  5. Different environment configuration

    We can configure asp.net core application for different environment like development, staging, production. Even we can have different application pipeline for different environment, "Configure" method of startup.cs allow us to setup pipeline for each environment.

    public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
    {
        if (env.IsDevelopment())
        {
            app.UseDeveloperExceptionPage();
            app.UseBrowserLink();
        }    
        else if (env.IsStaging())
        {
            // setup app pipeline here
        }    
        else if (env.IsProduction())
        {
            // setup app pipeline here
        }    
    }
    

    Learn more about Startup.cs File in Asp.Net Core application

  6. Dependency Injection (DI)

    Dependency Injection has been heavily used in Asp.net Core, almost in every situation, think of how logging used to be implemented in earlier version (creating a new instance of Logger), now logging can be implemented using Dependency Injection (concept of don’t call me, I call you), Here is an example of creating new object of HostingEnvironment using dependency injection through constructor.

    public class fileuploadController : Controller
    {
        private readonly IHostingEnvironment _hostingEnvironment;
    public fileuploadController(IHostingEnvironment hostingEnvironment)
    {
        _hostingEnvironment = hostingEnvironment;
    }
    }
    

    If you are new to DI design pattern, then must take a look at Dependency Injection implementation example in Asp.net

  7. Kestrel Webserver

    Kestrel is the new web server introduced with Asp.net Core, Kestrel is an event-driven, asynchronous I/O based web server for hosting ASP.NET applications. Kestrel web server drastically improve the performance of Asp.net application, it’s much faster compare to earlier server IIS.

    Learn more about Kestrel Webserver

  8. SignalR in Asp.net Core

    SignalR is the API introduced with Asp.net framework few years ago, initially there was some changeless implanting SignalR , Now in Asp.net core framework SignalR core is more optimised, can help us developing powerful real-time web application.

    We can develop real-time communication application like chat, stock market dashboard; cricket live scoreboard etc. here is an example of how you can write real time chat application with SignalR.

You may also look at ASP.NET Core 3.1 New Features

Asp.Net Core C# Examples | Join Asp.Net MVC Course