Search code examples
c#blazorsignalr.net-6.0background-service

How to call Windows background service in Blazor(.net6) web application?


How do I consume windows background service in my Blazor .net 6 web application.

I have created two projects, one is a background service and it is running on my machine and another is a Blazor web application. So How do I call running windows service in my web application?


Solution

  • Its generally not a good idea to "call a windows service" directly. If you want your background service to respond to web requests it should be hosted in IIS or kestrel, and called like a regular api. This is idea if you expect a response from your request. Otherwise I would suggest using a message broker such as rabbit mq to dispatch a request. Ideally the message would be sent by an endpoint exposed with your blazor app.