Reverseajax Reverse Ajax is a Web implementation pattern designed to transfer logical control to the server
What is the transfer of control rights
Traditional Ajax calls are typically triggered by client behavior, such as obtaining zone data, asynchronous validation, and so on.
Reverseajax transfers control to the server, just as the server triggers a client event, an early web-push technology.
Asp. NET implementation of a variable-length connection requires the use of technology to the asynchronous page, and the page needs to disable the session to implement each request to produce a new instance execution.
Copy Code code as follows:
<%@ Page language= "C #" autoeventwireup= "true" codefile= "Response.aspx.cs" inherits= "_default" async= "true" asynctimeout= "enablesessionstate=" "False"%>
if (request.form.count>0)
{
if (request.form["type"] = = "Loop")
{
Chattask task = new Chattask (this. context);
Task._chatnow = this. Chatnow;//has a callback method for new messages, that is, for notification processing, this time releasing the connection
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
}
}
For specific code and implementation effects, see the example.
Attachment:
Sample program: reverseajaxchat example. rar