locked
Call windows service from ASP.NET RRS feed

  • Question

  • User-2066177896 posted

    Hi,

    I have a windows service.

    From my asp.net appliaction, i want to call a method in windows service.

    How can i do it?

    Thanks

    Thursday, October 10, 2013 4:08 PM

Answers

  • User-1635195291 posted

    Hi rowter,

    Expose that method in your windows service as a WCF endpoint and call that from ASP.NET.

    Take a look at How to: Host a WCF Service in a Managed Windows Service.

    If 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.

    Hope this helps.

    Thanks,

    Jatin


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 10, 2013 8:26 PM
  • User197322208 posted

    , the user will select a few items on the asp.net page and click on  Sumit button. Then this method in windows service should run and update the database.

    From asp.net put the checked items into a table .

    Run the

    long running task atleast 30 min or more.
    in windows service from 31 to 31 minutes.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 11, 2013 2:51 PM

All replies

  • User197322208 posted

    put the method in a dll. Share the dll accross the applications( asp.net and windows service)

    Thursday, October 10, 2013 8:20 PM
  • User-1635195291 posted

    Hi rowter,

    Expose that method in your windows service as a WCF endpoint and call that from ASP.NET.

    Take a look at How to: Host a WCF Service in a Managed Windows Service.

    If 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.

    Hope this helps.

    Thanks,

    Jatin


    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Thursday, October 10, 2013 8:26 PM
  • User-488622176 posted

    Rowter,

    What do you want to achieve? What is your final goal? This will determine of you should call the method in the Windows service (by using something like WCF) or if it is sufficient to put the method in a shared assembly (DLL)

    Friday, October 11, 2013 4:01 AM
  • User-2066177896 posted

    Illeris, Ignatandrei:

    This is a very long running task atleast 30 min or more. We will have issues with running it on a asp.net application. So we are planning a windows service. This is not a automated task. So, the user will select a few items on the asp.net page and click on  Sumit button. Then this method in windows service should run and update the database.

    Friday, October 11, 2013 9:54 AM
  • User-2066177896 posted

    jats_ptl,

    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.

    I want to send a message to Windows service. I hosted a WCF inside a Windows service. I followed the steps given here in this link:http://msdn.microsoft.com/en-us/library/ms733069.aspx

    How do i expose the windows service to a ASP.NET application?

    Thanks

    Friday, October 11, 2013 9:57 AM
  • User197322208 posted

    , the user will select a few items on the asp.net page and click on  Sumit button. Then this method in windows service should run and update the database.

    From asp.net put the checked items into a table .

    Run the

    long running task atleast 30 min or more.
    in windows service from 31 to 31 minutes.

    • Marked as answer by Anonymous Thursday, October 7, 2021 12:00 AM
    Friday, October 11, 2013 2:51 PM