0

Some time ago when there were no ASP.NET-Core hosted-services the choice for a service-type application was pretty clear, it was a Windows Service. However, recently I've noticed that at least some people misuse hosted-service for this purpose. I've seen applications that had absolutely no REST API whatsoever and were just services.

Is this how this technology is supposed to be used now or is this just some new trend started by people who do not understand it? Me included... so I have a couple of questions:

  • What is the difference between the two in terms of services?
  • When should I use a classic Windows Service and when it is accetable to implement it as a hosted-service in a ASP.NET-Core application?
  • Do I still need Windows Service for anything or should I upgrade my current Windows Services to hosted-services?
  • close voters, can you not look past the phrasing of the title. It's clearly on topic to ask about how to use this tech – Ewan Mar 8 at 23:41
3

Hmm, there's not a lot of information about hosted services. Its hard to comment on the motivation for the idea, but I would say overall no.

  • What is the difference between the two (Windows service and Hosted Service)

    The hosted service runs as part of a .net core website. A windows service runs as its own application.

  • When should I use one or the other

    Honestly I would almost say "Never use a hosted service" The whole point of an 'offline' worker process is that it never goes down. Tieing one to a website seems counter productive. The various articles mention that if you host the site in iis for example, app pool recycles will stop and start your hosted services.

    The other use case would be offline tasks that are tied to your website. Recycling a cache is an example given. But its usually far better to tie these kind of tasks to the normal working of your website, ie when you receive a request than to have them on a schedule.

  • Do I still need Windows Service for anything

    Use windows services to make applications that should always be running. But its basically just an app that windows starts for you when it boots and reports on. There are alternatives if you are in the cloud, or using other operating systems etc

I would guess the reason for creating Hosted Services was to create an easy way for people to make background tasks when they were hosting their .net core web sites on linux and couldn't deploy a windows service

  • This sounds resonable and I wish the docs were more specific about it. Mhmm, perhaps I should ping the asp.net-core team on GitHub too... – t3chb0t Mar 8 at 20:42

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.