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 ".