Implementation example of Web instant application with variable length connection under ASP.net and Reverseajax demonstration Introduction _ Practical Skills

Source: Internet
Author: User
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
Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.