0

I'm building a windows service but I would like to get some web pages to control some settings, get diagnostics, etc...

How would you go about combining an asp.net web site AND a windows service together ? I know that WCF can be self hosted into an arbitrary process but can I do the same with asp.net ?

Another option would be to have my service logic in the asp.net web site application_start method to spawn long running threads. But then, I don't get window service built in feature such as auto start on boot up. Another issue might be that IIS might decide to recycle the process. Moreover, my service needs to open a raw tcp socket to accept connections. Can I do that in IIS ?

Thanks

Clement
  • 3,990
  • 4
  • 43
  • 44

3 Answers3

3

I think the easiest and most robust way to do this is to have an ASP.NET Web Site running under IIS on the same server as the Windows Service. The Windows Service can host a WCF Web Service that will be accessible to the ASP.NET application.

Joe
  • 122,218
  • 32
  • 205
  • 338
0

I would have your Windows service self-host a WCF "configuration" service. The WCF service only needs to be exposed locally if the UI is on the same machine. If the windows service needs to open a separate raw socket for communications this can punch a hole through the firewall.

Then the ASP.NET UI can be hosted by IIS as usual, and call the WCF methods to perform the configuration tasks.

devstuff
  • 8,277
  • 1
  • 27
  • 33
0

It seems like you really need both things—a web app hosted in IIS and a windows service hosted as windows service.

Then you can just share data between the two in some way, e.g. via a database.

Dmytro Shevchenko
  • 33,431
  • 6
  • 51
  • 67