468,306 Members | 1,138 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,306 developers. It's quick & easy.

How can I implement the "Pushing" mode in Asp.Net application

Hi,
As we know,in normal asp.net application, a browser need to send a
request to a server first to refresh its page. Now I need to design a asp.net
application with real-time capability like the MSN Web Messenger. That means
once the session between browser and server has been established, the
browser can get real-time messages with out sending requests periodically.(Or
How to tell the browser that you need to send a new request to refresh the
page.)

Thanks in advance!
Nov 18 '05 #1
6 1441
Hi,

you can implement automatic updating of the form using the form's META tag's
Http-Equiv property

<meta http-equiv = "Refresh" Content=60>

this will cause the browser to reload the page every 60 seconds. However,
the it is supported HTML 3.2 onwards compatible browsers.

HTH
Joyjit
"eXseraph" <eX******@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...> Hi,
As we know,in normal asp.net application, a browser need to send a
request to a server first to refresh its page. Now I need to design a asp.net application with real-time capability like the MSN Web Messenger. That means once the session between browser and server has been established, the
browser can get real-time messages with out sending requests periodically.(Or How to tell the browser that you need to send a new request to refresh the
page.)

Thanks in advance!

Nov 18 '05 #2
HTTP is a request-response protocol, so you must send requests periodically
to do this. You can use XMLHTTP to make callbacks to the server without
refreshing the page.

The following code is a XmlHttp factory (courtesy of WebFX):
function XmlHttp() {}

XmlHttp.create = function () {
try {
if (window.XMLHttpRequest) {
var req = new XMLHttpRequest();

// some older versions of Moz did not support the readyState
property
// and the onreadystate event so we patch it!
if (req.readyState == null) {
req.readyState = 1;
req.addEventListener("load", function () {
req.readyState = 4;
if (typeof req.onreadystatechange == "function")
req.onreadystatechange();
}, false);
}

return req;
}
if (window.ActiveXObject) {
return new ActiveXObject(getControlPrefix() + ".XmlHttp");
}
}
catch (ex) {}
// fell through
throw new Error("Your browser does not support XmlHttp objects");
};

function getControlPrefix() {
if (getControlPrefix.prefix)
return getControlPrefix.prefix;

var prefixes = ["MSXML2", "Microsoft", "MSXML", "MSXML3"];
var o, o2;
for (var i = 0; i < prefixes.length; i++) {
try {
// try to create the objects
o = new ActiveXObject(prefixes[i] + ".XmlHttp");
o2 = new ActiveXObject(prefixes[i] + ".XmlDom");
return getControlPrefix.prefix = prefixes[i];
}
catch (ex) {};
}

throw new Error("Could not find an installed XML parser");
}
You can use the code above to create XmlHttp objects that can be used to
call back to the server.The following snippet shows how to make an
asyncronous request:function loadAsync(sUri) {
var xmlHttp = XmlHttp.create();
var async = true;
xmlHttp.open("GET", sUri, async);
xmlHttp.onreadystatechange = function () {
if (xmlHttp.readyState == 4)
doSomething(xmlHttp.responseXML); // responseXML : XmlDocument
}
xmlHttp.send(null);
}You can find examples of how to serialize objects between the server and
the client and back in these blog
entries:http://dotnetjunkies.com/WebLog/anor...Regards,Anders
Noråsblog: http://dotnetjunkies.com/weblog/anoras/"eXseraph"
<eX******@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
Hi,
As we know,in normal asp.net application, a browser need to send a
request to a server first to refresh its page. Now I need to design a
asp.net
application with real-time capability like the MSN Web Messenger. That
means
once the session between browser and server has been established, the
browser can get real-time messages with out sending requests
periodically.(Or
How to tell the browser that you need to send a new request to refresh the
page.)

Thanks in advance!

Nov 18 '05 #3
This is a big issue. ASP.NET 2.0 will include this functionality but it's
still dificult to implement and maintain and I found that solution to be a
bit complicated in general. It will use the same principals I describe
below, though.

The easiest way to fetch data into page without postback is to use IE
behaviors, namely WebService behavior (Microsoft provides it for free). It
uses ActiveX built in IE 5.5 and does almost the same thing described by
Anders who answered your question earlier.
Because it can be interesting to everyone on this group I'll describe this
stuff a little bit:

The good thing about this is that your page which will render data from
server doesn't have to be written in .net or php or whatever server side
processing you use. It can be simple html page. All ActiveX objects used
here comes with IE 5.5 and above, so you need to make sure that your users
use this version of IE. The WebService behavior itself doesn't come with
IE - you have to get it (see below) and put on your server. You have to use
some sort of data supply/source. The easiest way is to use web service
(asmx) which you can create on your server.
So, the process is relatively simple:

1. You create one or thousand WebServices on your server which html page
will talk to to get the data it needs.
2. You load WebService behavior into your page (it's not a big file, IE will
cache it anyway). Normally I use div tag to hold this behavior and I
"attach" behavior to this div through css class
(.ws{behavior:url(/Blah/HTC/WebService.htc)}).
3. You can use "download" behavior included in IE to load WebService
behavior.
4. Now let's say that you need to pre-fill some text box with all last names
that exist in your db that start with letters user typed into this text box,
much like selection box or IE AutoComplete feature.
5. Your script should detect typing and "ask" the div tag to go to your
server and get particular data (all last names that start with typed
characters) and bring it back by loading it into <xml> tag. I create <xml>
tag on the fly if result from the server is not empty. Then the simple thing
like "var dso = document.all.xmlTagName.recordset;" will give you ADO
recordset with you use to create your selection box, loop through it,
whatever.

It's easy when you've done it before. It looks relatively difficult if you
just starting. Read about it here:
http://msdn.microsoft.com/library/de...e/overview.asp

Hope it helps,
Kikoz

"eXseraph" <eX******@discussions.microsoft.com> wrote in message
news:C0**********************************@microsof t.com...
Hi,
As we know,in normal asp.net application, a browser need to send a
request to a server first to refresh its page. Now I need to design a
asp.net
application with real-time capability like the MSN Web Messenger. That
means
once the session between browser and server has been established, the
browser can get real-time messages with out sending requests
periodically.(Or
How to tell the browser that you need to send a new request to refresh the
page.)

Thanks in advance!

Nov 18 '05 #4
the current problem with the IE web behavior, is that it is disabled with
xp-sp2 for security reasons. you can use it with intranet sites where you
can force the users to trust your site, but it will not work with an
internet site. this is probably why MSN uses a javascript and a hidden frame
to do the polling.

-- bruce (sqlwork.com)

"Kikoz" <ki***@hotmail.com> wrote in message
news:uY**************@TK2MSFTNGP12.phx.gbl...
| This is a big issue. ASP.NET 2.0 will include this functionality but it's
| still dificult to implement and maintain and I found that solution to be a
| bit complicated in general. It will use the same principals I describe
| below, though.
|
| The easiest way to fetch data into page without postback is to use IE
| behaviors, namely WebService behavior (Microsoft provides it for free). It
| uses ActiveX built in IE 5.5 and does almost the same thing described by
| Anders who answered your question earlier.
| Because it can be interesting to everyone on this group I'll describe this
| stuff a little bit:
|
| The good thing about this is that your page which will render data from
| server doesn't have to be written in .net or php or whatever server side
| processing you use. It can be simple html page. All ActiveX objects used
| here comes with IE 5.5 and above, so you need to make sure that your users
| use this version of IE. The WebService behavior itself doesn't come with
| IE - you have to get it (see below) and put on your server. You have to
use
| some sort of data supply/source. The easiest way is to use web service
| (asmx) which you can create on your server.
| So, the process is relatively simple:
|
| 1. You create one or thousand WebServices on your server which html page
| will talk to to get the data it needs.
| 2. You load WebService behavior into your page (it's not a big file, IE
will
| cache it anyway). Normally I use div tag to hold this behavior and I
| "attach" behavior to this div through css class
| (.ws{behavior:url(/Blah/HTC/WebService.htc)}).
| 3. You can use "download" behavior included in IE to load WebService
| behavior.
| 4. Now let's say that you need to pre-fill some text box with all last
names
| that exist in your db that start with letters user typed into this text
box,
| much like selection box or IE AutoComplete feature.
| 5. Your script should detect typing and "ask" the div tag to go to your
| server and get particular data (all last names that start with typed
| characters) and bring it back by loading it into <xml> tag. I create
<xml>
| tag on the fly if result from the server is not empty. Then the simple
thing
| like "var dso = document.all.xmlTagName.recordset;" will give you ADO
| recordset with you use to create your selection box, loop through it,
| whatever.
|
| It's easy when you've done it before. It looks relatively difficult if you
| just starting. Read about it here:
|
http://msdn.microsoft.com/library/de...e/overview.asp
|
| Hope it helps,
| Kikoz
|
| "eXseraph" <eX******@discussions.microsoft.com> wrote in message
| news:C0**********************************@microsof t.com...
| > Hi,
| > As we know,in normal asp.net application, a browser need to send a
| > request to a server first to refresh its page. Now I need to design a
| > asp.net
| > application with real-time capability like the MSN Web Messenger. That
| > means
| > once the session between browser and server has been established, the
| > browser can get real-time messages with out sending requests
| > periodically.(Or
| > How to tell the browser that you need to send a new request to refresh
the
| > page.)
| >
| > Thanks in advance!
|
|
Nov 18 '05 #5
I have numerous implementations of that scenario on several public sites.
WebService behavior doesn't seem to be blocked by SP2 at all. ModalDialog
does change its appearance as well as several other JScript objects but not
behaviors. "Microsoft.XMLDOM" ActiveX object which is used by WebService
behavior is included in IE and trusted by default. All my "no post backs"
code works just fine on all user SP2 machines. Again, although some of those
sites require registration and login, they all "public" and not "intranets"
on some local networks.
the current problem with the IE web behavior, is that it is disabled with
xp-sp2 for security reasons. you can use it with intranet sites where you
can force the users to trust your site, but it will not work with an
internet site. this is probably why MSN uses a javascript and a hidden
frame
to do the polling.

Nov 18 '05 #6
behaviors are the same, but Microsoft's XMLHTTP ActiveX object is not always
enabled.

-- buce (sqlwork.com)
"Kikoz" <ki***@hotmail.com> wrote in message
news:%2****************@TK2MSFTNGP14.phx.gbl...
| I have numerous implementations of that scenario on several public sites.
| WebService behavior doesn't seem to be blocked by SP2 at all. ModalDialog
| does change its appearance as well as several other JScript objects but
not
| behaviors. "Microsoft.XMLDOM" ActiveX object which is used by WebService
| behavior is included in IE and trusted by default. All my "no post backs"
| code works just fine on all user SP2 machines. Again, although some of
those
| sites require registration and login, they all "public" and not
"intranets"
| on some local networks.
|
|
|
| > the current problem with the IE web behavior, is that it is disabled
with
| > xp-sp2 for security reasons. you can use it with intranet sites where
you
| > can force the users to trust your site, but it will not work with an
| > internet site. this is probably why MSN uses a javascript and a hidden
| > frame
| > to do the polling.
|
|
Nov 18 '05 #7

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

11 posts views Thread by David Morgenthaler | last post: by
7 posts views Thread by William Payne | last post: by
169 posts views Thread by JohnQ | last post: by
reply views Thread by Teichintx | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.