![]() ![]() Basically, a Host allows you to have a similar infrastructure than what you have with WebHost (dependency injection, hosted services, etc.), but in this case, you just want to have a simple and lighter process as the host, with nothing related to MVC, Web API or HTTP server features. The WebHost uses these very same IHostedServices for background tasks.Ī Host (base class implementing IHost) was introduced in. It provides all the new infrastructure goodness in ASP.NET Core, enabling you to use dependency injection, insert middlewares in the request pipeline, and similar. Note the difference made between WebHost and Host.Ī WebHost (base class implementing IWebHost) in ASP.NET Core 2.0 is the infrastructure artifact you use to provide HTTP server features to your process, such as when you're implementing an MVC web app or Web API service. a HostĪSP.NET Core 1.x and 2.x support IWebHost for background processes in web apps.NET Core 2.1 and later versions support IHost for background processes with plain console apps. The basic idea is that you can register multiple background tasks (hosted services) that run in the background while your web host or host is running, as shown in the image 6-26.įigure 6-26. NET Core 2.0, the framework provides a new interface named IHostedService helping you to easily implement hosted services. ![]() Note that in this case, the hosted service simply means a class with the background task logic. NET we called these type of tasks Hosted Services, because they are services/logic that you host within your host/application/microservice. The difference when using a microservices architecture is that you can implement the background task in a separate process/container for hosting so you can scale it down/up based on your need.įrom a generic point of view, in. Background tasks and scheduled jobs are something you might need to use in any application, whether or not it follows the microservices architecture pattern. ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |