开发者

IIS vs Windows Service?

开发者 https://www.devze.com 2023-02-06 23:53 出处:网络
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 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.

0

精彩评论

暂无评论...
验证码 换一张
取 消