Code reading summary of the Fitch and Mather 7.0 (custom string Caching page)

Source: Internet
Author: User

In Menus_ascx we see a cached custom string "authenticated"

<%@ OutputCache duration= "86400" varybyparam= "None" varybycustom= "authenticated"%>

Note: @OutputCache directives are included with the required Duration and VaryByParam attributes. The Duration property must be set to any integer greater than 0. If you do not want to use the functionality provided by the VaryByParam property, set its value to None

Overriding the GetVaryByCustomString method in the Global.asax file

This is where the user control is cached based on whether the user validates it, that is, a validated user control, an unauthenticated user control

1public override String GetVaryByCustomString (HttpContext context, string custom)
2 {
3//There are two dif Ferent possible caching cases here, we return a different string in each one.
4 if (context. request.isauthenticated)
5 {
6//Request is authenticated
7 return "B";
8}
9 Else
{One
/Request is not authenticated the return
"C";
}
14}

Based on this idea, we can develop an example of caching pages that vary by browser type.

For example, our existing page is webform3.aspx, we can do page caching according to the type of browser we visit.

First add in the page

<%@ OutputCache duration= "varybyparam=" "None" varybycustom= "Ietype"%>

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.