473,387 Members | 1,721 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Push Alert to Browser

I am looking for architecture to push information from a server to a client
browser. This information would be in the form of an alert. What I do not
want to do is have the browser be on a timer and update every few seconds.
What options do I have to put into place such a feature?

Nov 16 '05 #1
14 2801
Your best, and probably easiest bet, is to avoid using push technology
entirely since it's too much of a pain to work with and died not long after
coming out of the box. The simplest thing I can think of is to just set a
meta tag for the page to refresh the page automatically. This is nice
because it doesn't involve any programming. The downside is it does refresh
the entire page. You could then create an inline frame that would present a
much smaller area of the page, and in this area have a web page called that
refreshes every so often. This should work, though I haven't toyed with an
embedded refresh like this in an iframe before.

When setting how often to refresh keep performance in mind. If you have a
number of browser windows open from different users then you'll start to get
a lot of constant hits checking for an alert status. This could drop the
performance down but you should be able to minimize it by doing some very
careful programming.

Hope this helps,
Mark Fitzpatrick
Microsoft MVP - FrontPage

"Nick K." <ni**@bogus.com> wrote in message
news:ei**************@TK2MSFTNGP14.phx.gbl...
I am looking for architecture to push information from a server to a client
browser. This information would be in the form of an alert. What I do not
want to do is have the browser be on a timer and update every few seconds.
What options do I have to put into place such a feature?

Nov 16 '05 #2
I have implemented this architecture in an enterprise application for a
mortgage company. We used a "Messaging" paradigm where there was a .NET
assembly loaded in a hidden IFRAME in a webpage that was invoked on the
client. On successful login, this assembly registered with a
server-side Windows Service that placed the client IP in a hashtable.
Every two minutes, the server "pinged" the client IPs in memory with a
two byte challenge to ensure they were still alive (i.e., the client
didn't close the browser or navigate to another site). If the server
did not receive a response, it removed that IP from its hashtable.

When a message needed to be pushed to the client, the server received a
..NET remoting call from our server-side app to push the message to a
particular user. The messaging server did a quick lookup in its
hashtable for a registered client IP that matched the unique login key
that was passed in through the remoting call. If it found the login
key, the messaging server would push the message to the client over
TCP/IP port 80 and the client assembly would pass the message to the
browser and dynamically update an HTML table on the page with the new
message. In your case, you could have IE pop up a messagebox or you
could create a custom Windows.NET form to show the message directly from
the embedded .NET assembly.

This has been in production for over a year with no problems and works
reliably.

Hope this helps.

Nick K. wrote:
I am looking for architecture to push information from a server to a client
browser. This information would be in the form of an alert. What I do not
want to do is have the browser be on a timer and update every few seconds.
What options do I have to put into place such a feature?

Nov 16 '05 #3
You cannot push to a browser.
Browsers do not support this capability.
The only way it could be done is to embed a lower level component in your
page, such as an ActiveX control. Then you'd have to write all the
networking code manually.

It is far more feasible to have the browser initiate communication on a
timed interval even if it's not ideal.

--
I hope this helps,
Steve C. Orr, MCSD, MVP
http://Steve.Orr.net


"Nick K." <ni**@bogus.com> wrote in message
news:ei**************@TK2MSFTNGP14.phx.gbl...
I am looking for architecture to push information from a server to a client
browser. This information would be in the form of an alert. What I do not
want to do is have the browser be on a timer and update every few seconds.
What options do I have to put into place such a feature?

Nov 16 '05 #4
"Nick K." <ni**@bogus.com> wrote in
news:ei**************@TK2MSFTNGP14.phx.gbl:
I am looking for architecture to push information from a server to a
client browser. This information would be in the form of an alert.
What I do not want to do is have the browser be on a timer and update
every few seconds. What options do I have to put into place such a
feature?


If you have ASP.NET 2.0 Beta, you can try doing ClientCallBacks.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 16 '05 #5
I am interested and have a few questions:

Your messaging server, is this a custom piece of code or a Microsoft
product?

The client assembly that receives the message, is this a custom piece of
code or a Microsoft product?

How exactly, does this client assembly pass the message to the browser?

Do you have a link to code that would explain any of this more, especially
the .Net assembly in the IFRAME or an assembly communicating with the
browser?

I am impressed with what you have done, especially since others say, "don't
try" or "it can't be done". Congratulations.
"Jason Bailey" <ja*************@hotmail.com> wrote in message
news:41**************@hotmail.com...
I have implemented this architecture in an enterprise application for a
mortgage company. We used a "Messaging" paradigm where there was a .NET
assembly loaded in a hidden IFRAME in a webpage that was invoked on the
client. On successful login, this assembly registered with a
server-side Windows Service that placed the client IP in a hashtable.
Every two minutes, the server "pinged" the client IPs in memory with a
two byte challenge to ensure they were still alive (i.e., the client
didn't close the browser or navigate to another site). If the server
did not receive a response, it removed that IP from its hashtable.

When a message needed to be pushed to the client, the server received a
.NET remoting call from our server-side app to push the message to a
particular user. The messaging server did a quick lookup in its
hashtable for a registered client IP that matched the unique login key
that was passed in through the remoting call. If it found the login
key, the messaging server would push the message to the client over
TCP/IP port 80 and the client assembly would pass the message to the
browser and dynamically update an HTML table on the page with the new
message. In your case, you could have IE pop up a messagebox or you
could create a custom Windows.NET form to show the message directly from
the embedded .NET assembly.

This has been in production for over a year with no problems and works
reliably.

Hope this helps.

Nick K. wrote:
I am looking for architecture to push information from a server to a client browser. This information would be in the form of an alert. What I do not want to do is have the browser be on a timer and update every few seconds. What options do I have to put into place such a feature?

Nov 16 '05 #6
this is available in net 1.0, it just javascript doing a postback.

-- bruce (sqlwork.com)
"Lucas Tam" <RE********@rogers.com> wrote in message
news:Xn***************************@140.99.99.130.. .
"Nick K." <ni**@bogus.com> wrote in
news:ei**************@TK2MSFTNGP14.phx.gbl:
I am looking for architecture to push information from a server to a
client browser. This information would be in the form of an alert.
What I do not want to do is have the browser be on a timer and update
every few seconds. What options do I have to put into place such a
feature?


If you have ASP.NET 2.0 Beta, you can try doing ClientCallBacks.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/

Nov 16 '05 #7
1) Push script commands down to an iframe via a persistent connection, more
or less like the well-known command pattern. Difficult, requiring good
kung-fu skills, but not impossible.

2) Use client-side jscript and XMLHTTP to download an XML document
asynchronously from the server. This is an IE 5.0 or later-only solution,
but Mozilla has a similar interface. I have an example below.

3) Wait for ASP.NET 2.0, which wraps #2 in an easier-to-use programming
model.
Here's the HTML+script example for #2 -- I put a simple XML doc up on
servergeek so you can test it.

<html>
<script>
var req = null;
function onUpdate()
{
req = new ActiveXObject("Msxml2.XMLHTTP.3.0");
req.open("GET", "http://www.servergeek.com/foo.xml", true);
req.onreadystatechange= HandleStateChange;
req.send();
}

function HandleStateChange()
{
if (req.readyState == 4)
{
alert(req.responseXML.xml);
setTimeout('onUpdate()', 1000);
}
}

</script>
<body onload="setTimeout('onUpdate()', 1000)">
<div id="target">X</div>
</body>
</html>
--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com

"Nick K." <ni**@bogus.com> wrote in message
news:ei**************@TK2MSFTNGP14.phx.gbl...
I am looking for architecture to push information from a server to a client browser. This information would be in the form of an alert. What I do not
want to do is have the browser be on a timer and update every few seconds.
What options do I have to put into place such a feature?

Nov 16 '05 #8


"bruce barker" <no***********@safeco.com> wrote in message
news:ex*************@TK2MSFTNGP14.phx.gbl...
this is available in net 1.0, it just javascript doing a postback.

-- bruce (sqlwork.com)

You don't need a postback, you just need to use XMLHTTP from javascript.
Nov 16 '05 #9
I am familiar with using Msxml2.XMLHTTP.on the client side. I have used such
javascript to call a web service. But that's not really pushing a message to
the client is it? If you have hundreds of users calling a web service every
few seconds, that's a lot of network traffic!

"Mickey Williams [C# MVP]" <my first name at servergeek dot com> wrote in
message news:uA**************@TK2MSFTNGP09.phx.gbl...
1) Push script commands down to an iframe via a persistent connection, more or less like the well-known command pattern. Difficult, requiring good
kung-fu skills, but not impossible.

2) Use client-side jscript and XMLHTTP to download an XML document
asynchronously from the server. This is an IE 5.0 or later-only solution,
but Mozilla has a similar interface. I have an example below.

3) Wait for ASP.NET 2.0, which wraps #2 in an easier-to-use programming
model.
Here's the HTML+script example for #2 -- I put a simple XML doc up on
servergeek so you can test it.

<html>
<script>
var req = null;
function onUpdate()
{
req = new ActiveXObject("Msxml2.XMLHTTP.3.0");
req.open("GET", "http://www.servergeek.com/foo.xml", true);
req.onreadystatechange= HandleStateChange;
req.send();
}

function HandleStateChange()
{
if (req.readyState == 4)
{
alert(req.responseXML.xml);
setTimeout('onUpdate()', 1000);
}
}

</script>
<body onload="setTimeout('onUpdate()', 1000)">
<div id="target">X</div>
</body>
</html>
--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com

"Nick K." <ni**@bogus.com> wrote in message
news:ei**************@TK2MSFTNGP14.phx.gbl...
I am looking for architecture to push information from a server to a

client
browser. This information would be in the form of an alert. What I do not want to do is have the browser be on a timer and update every few seconds. What options do I have to put into place such a feature?


Nov 16 '05 #10
"bruce barker" <no***********@safeco.com> wrote in news:ex3jmVopEHA.376
@TK2MSFTNGP14.phx.gbl:
this is available in net 1.0, it just javascript doing a postback.


ASP.NET 2.0's Client Callback is much more than a postback. Actually you're
not postingback a page at all.

Rather, ASP.NET can dynamically update a webpage using the XMLHTTP object.
Most of the update logic is encapsulated in VB.NET so you don't need to
mess with Javascript + XMLHTTP.

You can emulate ASP.NET 2.0's Callback feature by calling the XMLHTTP
object via Javascript manually... of course without .NET 2.0, it's a bit
ugly to do.

--
Lucas Tam (RE********@rogers.com)
Please delete "REMOVE" from the e-mail address when replying.
http://members.ebay.com/aboutme/coolspot18/
Nov 16 '05 #11
>If you have hundreds of users calling a web service every few seconds,
that's a lot of network traffic!

A lot? How much is a lot? It depends. The best solution depends on many
things, including the number of users you need to support, the network
topology, the server hardware you're using, the failure modes you prefer,
and the code complexity you're prepared to deal with.

Look - you essentially have two families of options, neither of them
especially scalable. I outlined both. I've used both. Each of them could be
called a better solution for specific situations. You need to have someone
with architectural skills evaluate the options. There's no need to be a
smart-ass when people try to help.

If the client can specify exactly what it wants, it's generally better to
have the client request the data, especially when combined with an effective
caching strategy. Even a commodity server can handle hundreds of users
calling back for small XML fragments if you know what you're doing.

OTOH, if the server is the only party that can determine when/what needs to
be updated, you can go the persistent connection route, but it's non-trivial
to implement, and it's not exactly a scalability winner either - state and
cache management can be difficult to handle. Can you handle the case where a
client misses an update? Does the client watchdog the server? What happens
if the watchdog expires? How do you resynchronize when required? If you're
serving from a farm, what happens when you lose a farm element? How do you
serve fairly in a farm -- or do you tolerate imbalances? There are a large
number of edge cases that complicate a real push implementation.

--
Mickey Williams
Author, "Visual C# .NET Core Ref", MS Press
www.neudesic.com
www.servergeek.com
Nov 16 '05 #12
See below...

Nick K. wrote:
I am interested and have a few questions:

Your messaging server, is this a custom piece of code or a Microsoft
product? Custom C# Windows Service on Windows 2003 Server

The client assembly that receives the message, is this a custom piece of
code or a Microsoft product? Custom C# Class
How exactly, does this client assembly pass the message to the browser?

Do you have a link to code that would explain any of this more, especially
the .Net assembly in the IFRAME or an assembly communicating with the
browser? The coding was done through researching many different sites and ,
together, building the solution that I've outlined. There's not any one
site that gives you everything. Most of what we needed to build the
plumbing was found on MSDN.
I am impressed with what you have done, especially since others say, "don't
try" or "it can't be done". Congratulations.
"Jason Bailey" <ja*************@hotmail.com> wrote in message
news:41**************@hotmail.com...
I have implemented this architecture in an enterprise application for a
mortgage company. We used a "Messaging" paradigm where there was a .NET
assembly loaded in a hidden IFRAME in a webpage that was invoked on the
client. On successful login, this assembly registered with a
server-side Windows Service that placed the client IP in a hashtable.
Every two minutes, the server "pinged" the client IPs in memory with a
two byte challenge to ensure they were still alive (i.e., the client
didn't close the browser or navigate to another site). If the server
did not receive a response, it removed that IP from its hashtable.

When a message needed to be pushed to the client, the server received a
.NET remoting call from our server-side app to push the message to a
particular user. The messaging server did a quick lookup in its
hashtable for a registered client IP that matched the unique login key
that was passed in through the remoting call. If it found the login
key, the messaging server would push the message to the client over
TCP/IP port 80 and the client assembly would pass the message to the
browser and dynamically update an HTML table on the page with the new
message. In your case, you could have IE pop up a messagebox or you
could create a custom Windows.NET form to show the message directly from
the embedded .NET assembly.

This has been in production for over a year with no problems and works
reliably.

Hope this helps.

Nick K. wrote:
I am looking for architecture to push information from a server to a
client
browser. This information would be in the form of an alert. What I do
not
want to do is have the browser be on a timer and update every few
seconds.
What options do I have to put into place such a feature?


Nov 16 '05 #13
There's a catch to this though. You have to have the .NET framework installed
on the clients as well as the server. Otherwise the client-side assembly
won't work.

I've been trying to come up with a good solution to this myself. It's
interesting that this can be done in Java (servlets, JavaScript, & DHTML see
http://www.pushlets.com) pretty easy, but it seems to be a real chore in .NET.

Eric

"Jason Bailey" wrote:
I have implemented this architecture in an enterprise application for a
mortgage company. We used a "Messaging" paradigm where there was a .NET
assembly loaded in a hidden IFRAME in a webpage that was invoked on the
client. On successful login, this assembly registered with a
server-side Windows Service that placed the client IP in a hashtable.
Every two minutes, the server "pinged" the client IPs in memory with a
two byte challenge to ensure they were still alive (i.e., the client
didn't close the browser or navigate to another site). If the server
did not receive a response, it removed that IP from its hashtable.

When a message needed to be pushed to the client, the server received a
..NET remoting call from our server-side app to push the message to a
particular user. The messaging server did a quick lookup in its
hashtable for a registered client IP that matched the unique login key
that was passed in through the remoting call. If it found the login
key, the messaging server would push the message to the client over
TCP/IP port 80 and the client assembly would pass the message to the
browser and dynamically update an HTML table on the page with the new
message. In your case, you could have IE pop up a messagebox or you
could create a custom Windows.NET form to show the message directly from
the embedded .NET assembly.

This has been in production for over a year with no problems and works
reliably.

Hope this helps.

Nick K. wrote:
I am looking for architecture to push information from a server to a client
browser. This information would be in the form of an alert. What I do not
want to do is have the browser be on a timer and update every few seconds.
What options do I have to put into place such a feature?

Nov 16 '05 #14
Ric
Technically, you can not 'really' push from the server.
However, if someone browses to a site you own, you can do a managed pull.
On IE (with xmlHttp), you have to poll the server, which can consume alot of
resources.
Howver, on Mozzilla, you can do ONE request, and let the server respond as
events happen with no time out and without polling the server.
Note: IE can do something similar with IFRAMES (yuck!) or Remote Scripting
(Insecure).

See my other posts to see an example
Nov 17 '05 #15

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

8
by: Michele | last post by:
Hi all, I have developed a PHP-based website where a "planner" user can make up schedules of activities to be performed, storing them into MySQL tables. Afterwards, other "watcher" users can...
3
by: Andrew Phillipo | last post by:
In IE5 I am working with a lot of code that uses Array.push() as well as for(var i in myArray) {} Great - so I'm fixing the Array.prototype.push function for browsers without it. That...
6
by: Rob Heckart | last post by:
Hi, I'm using the Portal ASP.NET starter kit for a project. It uses one aspx page, DesktopDefault.aspx to render content by loading different user controls depending on what's clicked. One of my...
14
by: Nick K. | last post by:
I am looking for architecture to push information from a server to a client browser. This information would be in the form of an alert. What I do not want to do is have the browser be on a timer...
3
by: Daz | last post by:
Hi everyone. First of all, I would be interested to know if anyone knows of a decent plugin for IE that validates JavaScript. I am running IE 5, 5.5 and 6 through wine (Windows Emulator) on...
4
by: Reid LI | last post by:
I just know I can do something in HTTP header like <meta http-equiv="refresh" content="5"> but can ASP.NET push, for example, new database content to browser automatically without using browser...
10
by: dharyl | last post by:
Hi Everyone, I'm dharyl from Philippines, I had a problem in knowing the user's browser Language. I was asked to have an alert pop up when the user of the site is using other language than...
10
by: Terrence Brannon | last post by:
Hello, The most common way of dynamically producing HTML is via template engines like genshi, cheetah, makotemplates, etc. These engines are 'inline' --- they intersperse programming...
8
by: knkk | last post by:
Instead of an id getting its innerHTML changed, the entire page is getting refreshed with this function of mine (you may want to look just at the end of the function where there's an alert): ...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.