asp.net application_acquirerequeststate event, causing AJAX client to not load _ practical tips

Source: Internet
Author: User
The development environment IIS7 all normal, but after deployment to the IIS6 server, every time the page refreshes the AJAX client can not load the problem.
Copy Code code as follows:

protected void Application_acquirerequeststate (object sender, EventArgs e)
{
String oldtoken = session["token"]. ToString ();
}

MSDN says: application_acquirerequeststate, executed when ASP.net gets the current state (such as session) associated with the current request.
However, the reality is that when we use an AJAX control, a page triggers the event multiple times, and the session appears null.
The reason is that some scripts and pictures are parsed through WebResource.axd handler, but when a page uses multiple scripts and pictures, the page requests multiple times.
Has triggered this event many times.
Therefore, to access the session in an event, you need to first determine whether the session is null.
Alternatively, we first determine the type of request.
 code as follows:

if (Request.Url.AbsoluteUri.Contains (". Axd") | | Request.Url.AbsoluteUri.Contains (". asmx"))
Return

Two days of pent-up, released, marked.
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.