4

I need to develop windows service which will do fortnightly transfers of files into the system. The problem is that I will also need "RunNow" method, so users can call transfer method any time by clicking to the link in the web app (asp.net mvc).

How can I call my windows service methods from external resource?

Gab
  • 471
  • 3
  • 10
  • 25
  • Look at WCF - http://msdn.microsoft.com/en-us/library/ms731082(v=vs.110).aspx. – Daniel Kelley Jun 17 '14 at 07:14
  • I know that it's possible with .net remoting, but I can't find examples. – Gab Jun 17 '14 at 07:40
  • WCF is not .Net remoting, and if you are looking for examples then that is off-topic for SO. You need to be explicit about what you need help with. – Daniel Kelley Jun 17 '14 at 07:45
  • One way to achieve true "run now" is make your service listening to the TCP port. In this case your service doesn't even need to have timers, etc. Once it receives a ping it starts execution – T.S. Jun 17 '14 at 08:22

2 Answers2

3

If you want to call a windows service method on the server side of your web application then take a look at the WCF or RestSharp and Nancy. Shortly, you need to create a RESTfull service in the windows service application that will be using a http://localhost/myservice/transfer address to expose the Transfer method. Then use ajax from your javascript code or RestRequest from your .net-controller class to call the address. But if you want to call a windows service method on the client side of the application it will be a problem.

sedovav
  • 1,986
  • 1
  • 17
  • 28
1

You could use Microsoft Message Queuing

The Webapplication would send a Message that the Service picks up.

Queue-Based Background Processing in ASP.NET MVC Web Application

http://msdn.microsoft.com/en-us/library/ms978430.aspx

Community
  • 1
  • 1
Mathias F
  • 15,906
  • 22
  • 89
  • 159