views:

1466

answers:

2

If I create a Windows Service, is there a way to call that service from asp.net?

+4  A: 

By

"Call that service"

do you mean, manage the service? As in, Start, Stop, Restart etc? If so, then the answer is yes. There is a good article at www.csharp-examples.net that will show you how to use the ServiceController class.

If however, you mean send messages to it, as if it's a Web Service, then, the answer is, that depends on how you're exposing your service. Windows Services can host WCF services, so that would be a good option, if you wanted to expose your windows service to internet clients.

Scott Ferguson
+2  A: 

Some clarity would help - you could also interpret "call that service" as some sort of remote method call from ASP.NET to your service - e.g. to store some state in your Windows Service.

Host a service endpoint in the Windows Service e.g. using Remoting, WCF, or plain ol' TCP socket server. All of which could be called by clients hosted in ASP.NET.

There are plenty of remoting and WCF examples out there that do just that - search for hosting and one of those technologies.

Some MSDN linkage to read:

Remoting

WCF

You should also read about Windows Process Activation - you may be able to get away without writing a seperate service.

stephbu