Solution to page download caused by outputcache

Source: Internet
Author: User

ASP. NETInOutputcacheIt is very useful, but when it comes to Browser Download pages, it is very confusing. FinallySearchAfter half a day, all the solutions found were addedVarybyheader = "Content-Type. However, after adding the file, the file will still be downloaded even if it does not work.

 

Finally, askDuduThen, a perfect solution is provided, which is rewritten.Global. asaxInApplication_beginrequestMethod to Determine the page type. If it is"Text/vnd. WAP. WML", The page is not cached. After high-traffic tests, this method is reliable and feasible, and has no performance problems. You can use it with confidence.

 

Code:

 

 

  Protected     Void  Application_beginrequest (Object sender, eventargs E)

{

// Use outputcache

String Accepttypes = Request. headers [ " Accept " ];

If ( ! String . Isnullorempty (accepttypes) && Accepttypes. tolower (). Contains ( " Text/vnd. WAP. WML " ))

{

Response. cache. setcacheability (httpcacheability. nocache );

}

}

 

After use CPU Occupied, immediately reduced , Use the following remarks Outputcache Benefits : Directly Reading pages from the memory, the page response speed is faster, and the user experience is better. This greatly reduces the pressure on the server, especially for highly concurrent websites, especially CPU Reduced Pressure DB And lower DB (Database) pressure.

 

The above is Solution for page download caused by outputcache. If it is helpful to you, please leave a message or click "recommended ".

 


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.