Home Update How to make use of IHostedService in ASP.Net Core

How to make use of IHostedService in ASP.Net Core

293


We typically must execute background duties and scheduled jobs in our functions. To implement background duties in ASP.Net Core, you’ll be able to benefit from Azure WebJobs or any of a lot of third-party process schedulers like Quartz or Hangfire.

In ASP.Net Core, you’ll be able to implement background duties as hosted companies as nicely. A hosted service is a category that implements the IHostedService interface and consists of the required code for operating duties within the background. This article presents a dialogue of how we are able to construct hosted companies in ASP.Net Core.

At the time of this writing, Visual Studio 2019 is obtainable without spending a dime obtain. If you don’t have already got a duplicate of Visual Studio 2019 put in in your system, you’ll be able to obtain it from Microsoft’s Visual Studio downloads web page. 

Create an ASP.Net Core mission in Visual Studio

First off, let’s create an ASP.Net Core mission in Visual Studio. To do this, observe the steps given under to create a brand new ASP.Net Core mission in Visual Studio 2019.

  1. Launch the Visual Studio IDE.
  2. Click on “Create new project.”
  3. In the “Create new project” window, choose “ASP.Net Core Web Application” from the checklist of the templates displayed.
  4. Click Next. 
  5. In the “Configure your new project” window, specify the title and placement for the brand new mission.
  6. Click Create.
  7. In the “Create New ASP.Net Core Web Application” window, choose .Net Core because the runtime and ASP.Net Core 2.2 (or later) from the drop-down checklist on the prime.
  8. Select “Web Application” because the mission template.
  9. Ensure that the test containers “Enable Docker Support” and “Configure for HTTPS” are unchecked as we received’t be utilizing these options right here.
  10. Ensure that Authentication is ready as “No Authentication” as we received’t be utilizing authentication both.
  11. Click Create. 



Source hyperlink

LEAVE A REPLY

Please enter your comment!
Please enter your name here