According to the company's recent training materials, the attachment includes a complete example of using a Web instant chat room with a variable length connection and a PPT training document for reverseajax, the PPT contains examples.Program.
Reverseajax invert Ajax is a Web Implementation Mode Designed to transfer logical control to the server.
What is Control Transfer
Traditional Ajax calls are generally triggered by client behavior, such as regional data acquisition and asynchronous verification.
Reverseajax transfers control to the server, just as the server triggers client events, that is, a very early web push technology.
ASP. NET requires the asynchronous page technology to implement a variable-length connection, and the session must be disabled for the page to generate a new instance for each request.
<% @ Page Language = " C # " Autoeventwireup = " True " Codefile = " Response. aspx. CS " Inherits = " _ Default " Async = " True " Asynctimeout = " 30 " Enablesessionstate = " False " %>
If (Request. Form. Count>0 )
{
If (Request. Form [ " Type " ] = " Loop " )
{
Chattask = New Chattask ( This . Context );
Task. _ chatnow = This . Chatnow;// There is a new callback method for the message, that is, notification processing. At this time, the connection is released.
String User = request. Form [ " User " ]. Trim ();
Pageasynctask async = New Pageasynctask ( New Begineventhandler (task. onbegin ), New Endeventhandler (task. onend ), New Endeventhandler (task. ontimeout), user );
Page. registerasynctask (async );
Page. executeregisteredasynctasks (); // Asynchronous execution
}
}
DetailsCodeFor more information, see examples.
Attachment:
Presentation: reverseajax.pptx
Example program: reverseajaxchat .rar