Click here to Skip to main content
15,029,128 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Freinds,

I have to develop a Network device monitoring software. I want it to divide in two part.
1. Windows Service
2. Website running on IIS
First will be a windows Service which will poll network device, query database and send notification to Website ( running in same server) which will responsible for presentation.

Please help how can a Windows Service communicate to a IIS7 hosted website in C#. Example will be appropriated.

Thanks in advance.
Updated 14-Dec-14 9:27am

Example for what exactly?
What have you tried so far, where are you stuck? This is not a "quick answers" kind top topic. We won't do your job, this community is pelased to help you pass trough concrete technical problems. Based on what you wrote, you have a set of requirements, and no idea how to start. Well, that's bad for you. First of all, because your approach looks incorrect. As far as the service is polling the devices, that's fine. But the website is passive, it will react on client requests, so you might find the web application killed (depending on page load, wery often actually) - so you can't notify it. The correct approach is the other way: the client (if there is any) should request IIS and the web application for data to update the presentation - using an ajax call for example. The web application could poll the databstore (database) or the service itself for new data. This is the old scool approach.

But there are some technologies you might consider using, like skipping IIS and using WebAPI hosted in the Windows Service itself, or letting the client contact the Windows Service directly using WebSocket and so on...

As you can see, you need to plan a good architectural design, look around available technologies and methods, constrainted by your other requirements you haven't told us. But all this is subordinated to the actual use of the whole solution, which is not clear from what you wrote.
Hi, since you're a newbie to this field, you first need to understand the concept of a WCF (Windows Communcation Foundation) and the client (which in your case is a website). First step is to create the service, which in real is an interface to be implemented by a host. The host can be anything that can accept the requests from clients; in most cases is just a Console application. Then you will create a simple library, which will be used to implement the interface of your service, and add the functionality to it (if you've got the empty functions in your interface then you need to declare them too).

Once done, you can simply just use those services (Add service reference in your website) in your website, to consume those service libraries. Once added, you can then follow on to use those resources and call the methods to perform different tasks.

Read my article on this topic, and download the sample if you want to test this functionality. Creating a Web Service to be consumed by connected Devices via Internet[^]

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900