Refresh web page when receive a message?

R

rockdale

Hi, all

I am coding a asp.net application as user data entry and report
interface. We also have another C#.net appplication (a server) does
some other stuff, my webserver can send and receive message with the
C#.net server application. Now the C#.net server application group want
me to refresh my webpage to show the real time status when I receive a
message from them. I do not think I can do that (correct me if I am
wrong). On webserver I can receive the message from them, but I do not
think I have any mechanism to notify a connected IE client to refresh
his webpage, or is there any httpresponse can archieve. What I can do
is to set my webpage to refresh every 5 second, is that the best way to
do this, or is there any way to send a message to client web page?


Thanks in advance
-Rockdale
 
L

Laurent Bugnion

Hi,
Hi, all

I am coding a asp.net application as user data entry and report
interface. We also have another C#.net appplication (a server) does
some other stuff, my webserver can send and receive message with the
C#.net server application. Now the C#.net server application group want
me to refresh my webpage to show the real time status when I receive a
message from them. I do not think I can do that (correct me if I am
wrong). On webserver I can receive the message from them, but I do not
think I have any mechanism to notify a connected IE client to refresh
his webpage, or is there any httpresponse can archieve. What I can do
is to set my webpage to refresh every 5 second, is that the best way to
do this, or is there any way to send a message to client web page?


Thanks in advance
-Rockdale

You are correct in the sense that a page refresh must be initiated from
the client. The server has no way to talk to the server directly, except
if you include a Java applet or another active content opening a direct
connection to the web server, with all the security issues that it means
(opening a new port...).

However, you also don't need to refresh the page periodically. The best
way is to use AJAX to periodically poll the server. Check AJAX on
google, there are many examples around.

If responsiveness is critical (if the web page must be updated as soon
as possible after an event occurs), you may want to look into COMET,
which is another way to do AJAX. In short, you send a request to the web
server, and wait on the server until either a message arrives, or a
timeout. As soon as the response arrives on the client, it sends a new
request, etc... Note that COMET in today's web servers has many issues,
and is not really recommended unless your server can take the load.

HTH,
Laurent
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,770
Messages
2,569,583
Members
45,073
Latest member
DarinCeden

Latest Threads

Top