473,385 Members | 1,829 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,385 software developers and data experts.

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 1699
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

11
by: David Morgenthaler | last post by:
How does one overide the iterator implied by the construct "for line in file:"? For example, suppose I have a file containing row,col pairs on each line, and I wish to write a subclass of file...
7
by: William Payne | last post by:
Hello, have you seen a recent files menu in a GUI application? In many GUI applications there's a menu the displays the most recent files that has been opened by the program. Say such a menu has...
81
by: Matt | last post by:
I have 2 questions: 1. strlen returns an unsigned (size_t) quantity. Why is an unsigned value more approprate than a signed value? Why is unsighned value less appropriate? 2. Would there...
1
by: francescomoi | last post by:
Hi. I've developed a web application which handles a big ammount of data (acquired via web form), so it takes 30-40 seconds to show the result. In order to calm down users, I want to...
50
by: Shadow Lynx | last post by:
Consider this simple HTML: <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 STRICT//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd"> <html xmlns="http://www.w3.org/1999/xhtml" > <head>...
169
by: JohnQ | last post by:
(The "C++ Grammer" thread in comp.lang.c++.moderated prompted this post). It would be more than a little bit nice if C++ was much "cleaner" (less complex) so that it wasn't a major world wide...
3
by: BobRoyAce | last post by:
I am using Visual Studio 2008 w/ VB.NET. For the database, I am using SQL Server 2005, which is running on a dedicated server box. I am creating a WinForms application for a client. It is run...
0
by: raylopez99 | last post by:
I ran afoul of this Compiler error CS1612 recently, when trying to modify a Point, which I had made have a property. It's pointless to do this (initially it will compile, but you'll run into...
3
Curtis Rutland
by: Curtis Rutland | last post by:
OK, I have a question. I have a problem. I'm trying to catch all KeyDown events on a button, but the problem is when I press the "Enter" key, the button's "Click" event is triggered, not the...
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: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
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: 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
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

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.