Caching a user control in ASP.NET?

后端 未结 4 434
鱼传尺愫
鱼传尺愫 2021-01-18 02:43

I have created a user control in my application \"header.ascx\", I am pasing a selectedMenu attribute to this control on which the control selects the selectedMenu value spe

4条回答
  •  暗喜
    暗喜 (楼主)
    2021-01-18 03:06

    To summarize

    using VaryByCustom, means

    1- Build the control again.
    2- Having multiple versions of the control in the cache. which will be used when the custom conditions meet.

    This is only good if the control is taking a lot of time to build and we have finite number of cached versions to not waste memory, and the application will need to access control properties (while it is cached "or null").

    but it will not be good if that custom conditions are depending on the control properties itself. I can't access it, it is null.

    for example I want to write something like if (the default selected value in countries list is NOT USA) then rebuild and Cache (give it a different string)

    Otherwise don't

    while other objects are trying to access the contries list, it will check for null, and set the countries drop down list to USA.

    The data cahing will do the work. it is the only way.

    who agree?

    Thanks for ur time

提交回复
热议问题