Communicating and Controlling web page from C#
I have already opened a webpage in Firefox which is actually running through the apache web server on the same machine. And I have C# application running on the same machine. Now I want to refresh/inform my already open web page that C# has finished processing. I have seen the threads all over the web and also some similar threads on Stackoverflow but did not find solution.
Any idea how to solve this?
In details: C# Application is transferring images from external storage. Web page (http://127.0.0.1/mypage.php) is looking for the images periodically, but never know that all images are transferred or not so that it can 开发者_如何学JAVAprocess these images to do some more work. In this scenario, we want to tell our web page (which is already running in firefox) all data transferred and now you can refresh to process data.
Two steps: Let the server communicate that C# is done, and have the web page react to it
You somehow need to expose the fact that the C# program has finished to the web. If you also have an IIS running, this could be done via a URL served by IIS directly that returns a value indicating whether C# is still running or not. If you don't, you can write to a file, database or whatever and have a script on your Apache server that checks for this value. Whatever you choose, you want something like www.myserver.com/are_you_finished.[php, aspx, whatever] that returns 1 or 0
Then, you can build JavaScript script in your client page that periodically checks this URL and reacts as soon as the value is 1. This would be a typical AJAX call, ie you need to play with XmlHttpRequest. This could be elaborated much further, but maybe you first say if that's what you have in mind, and I also think there's a lot of good documentation on how to do this on here.
You can include a Internet Explorer control in ouyr appliacation. This way you can control which page is displayed and you can call refresh and whatever you want.
Another way is to include a meta refresh tag in the html page so it periodically looks for updates and refreshes ifself.
I see no way to remote control firefox. The only thing i could think of is remember the process id when you start firefox, and the you kill the process and start a new window, but I consider this bad style.
精彩评论