I have a clean up service that needs to be ran on a schedule and sometimes on demand. My first thought was to create a windows service but a windows service cant be ran on demand. So, I am thinking of creating a ASP.NET web api site to run this background process. This way I can run the cleanup service on demand from a webpage and I can have a windows service call the web api url to run the service.
So there will be a Web API site that will execute the cleanup logic and both a webpage and a windows service can call this web api service to cleanup.
Do you see anything wrong with this idea? Is there a better way to do this
Related
I've just created a simple asp.NET web service application with a WebMethod that passes the current server time and a Windows form application to run alongside this as a client.
As it stands, for the client app to be able to interact with the server app, the web service application needs to be running (runs in a web browser). If the browser is then closed, the client app cannot talk to the web service app.
Ideally, I would need this web service to always be running in the background on my server at all times (not just when a web browser is opened) and start when the server is booted up.
What would be the best way to achieve this? I have minnimal experience with asp.NET so is there a way to configure the web service to be a background service? Do I need to create a seperate Windows service application that uses asp.NET web services?
Any help appreciated, thanks.
Yes, by default, Visual Studio stops debugging your web application when you close the browser used for debugging... But you shouldn't run your application from Visual Studio. You deploy web applications to IIS. Then they'll start when the machine starts, and they don't need a browser to keep running.
I have one windows service application and one ASP.NET web application, both created by C#. Both applications get data from the database(SQL server).
Once I update database from web application, how could I inform service application to reload data from database?
Right now our solution is to use service controller to restart windows service application. Is there any low cost solution, like communication between service application and web application?
By the way, my boss hate polling method...
If wcf is a choice, can anyone post some materials?
Thanks a lot!
you can implement workflow services that runs as a windows service. That service must have an activy that can be called over net.tcp request and processes your request. I'm using this solution and works fine.
Other way is the service use the database to check if it's necessary to perform the reload.
You can take advantage of Service Broker
In a nutshell: using the SqlDependency class you can wire up an event in C# that will fire whenever a table gets updated. At that point in time, you can re-load the new data.
I have created 2 WCF service libraries in a solution. I have also created two windows services which will host the two wcf services.
these wcf services communicate with eachother. one gets requests and is reusable service for other systems, the other service sends requests to this service and takes requests from the UI.
I have created installers for the window services too.
I want to understand the build script tasks which I need to include which I will call during each time I want to deploy this solution to the server?
Should I delete all of the windows services and install again with new DLLs?
What is the best way
There is no need to delete the windows services. You can stop the service, replace the service executable and all the assemblies used by your service and restart the service. This is what I've always done, and I've never run into problems.
I have a C# application that needs to always be running. I originally planned on making this a windows service but I now have a requirement to make the application host a web admin console.
I haven't played with IIS in quite a few years so my question is this:
What would you recommend I use?
I've thought about making a windows service and embedding a web server such as Cassini but so far I'm not very happy with the open source web servers I've looked at.
Can IIS handle this? Do people use it for this type of scenario, and if so how?
This sounds like a job for two separate projects.
One is the original Windows Service. Windows Services are well suited for what you're doing.
The second is the Web Project that will be used to administer the Windows Service. This is the part that runs in IIS.
It depends on what you mean by always running. An ASP.NET web application deployed in IIS could very well be unloaded by the web server if there aren't any requests for certain amount of time killing all background threads. So if you want an ever running background thread it would be better suited to use a Windows Service. As far as the web admin is concerned, well, here you don't have much choice: ASP.NET in IIS. In order to do something useful those two applications should be able to find a common language to talk. So you could use a database to store the results into which could be used by both applications.
IIS will run your app on first request, not on server boot. So you will still need to run a service to ensure your app is always running.
You can use IIS as a webserver for your web admin part, and link your ASP.net app with your service by means of a configuration database (easy) or webservices (a little more tricky).
Windows and Web services are two very different creatures. A web service will expose external methods that you can implement against an application, while a windows service is an entity within itself. If you're planning on using this service on a timed interval to perform an operation, a Windows service would be the right way to go. If you use a web service, you will need to invoke the method you wish to run from a secondary application.
If you need to queue commands against your windows service, you could always create a database that was accessible by both your website and your windows service. This way you could send commands and query data between the two. Placing a web service in to serve as an intermidary between the two may be overkill.
I have a asp.net web site, I would like a page on that site to be able to invoke a Windows Scheduled task or a batch file on a server different to the IIS server?
Is it possible?
How should I do this?
Simplest way would be to place a Web Service on the server that needs to run the scheduled task/batch file (we'll call this SERVER1). That service should have a method that will invoke the scheduled task/batch file (we'll call this method Invoke).
Then from the asp.net web site on the other server (SERVER2), we'll add a link to run our method on SERVER1, http://SERVER1/YourWebService.asmx/Invoke.
To me this would be the easiest way to manipulate SERVER1 from an outside entity (In your case an asp.net web site).
Note: You may run into security issues with your Web Service invoking scheduled tasks and running batch files. I believe it can be done, but you may need to play with your .Net permission settings.
Try PsExec. It's a free tool from Microsoft that will let you execute processes remotely.
Make sure to check out all the other tools in the Sysinternals Suite; there's some really good stuff in there.