简体   繁体   中英

Restart and monitor service from Website in IIS

I have a console application that monitors a folder for imports and parses them. I want to convert this to a Windows Service. What I'm not sure how to do or if it's possible is have an IIS hosted website be able to show the status of that service and manually restart it if necessary. The website and the windows service would be running on the same server.

Yes, you can create a website that checks for the status and restarts the Windows Service by using the ServiceController class. You can refer to this answer (or even the official documentation ) for sample code on both checking the status and restarting the service.

Just keep in mind that the website will have to run (under IIS settings) with a user identity that has enough privileges (normally administrator) on the server.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM