27 Haz 2011

Asp.Net Outputcache Webconfig Ayarları

Asp.Net TARAFI
[OutputCache(CacheProfile = "MyCacheProfile", VaryByParam = "strContentName", VaryByCustom = "userName")]
public ActionResult Detail() //Controller
{
}
[OutputCache(CacheProfile = "MyCacheProfile", VaryByParam = "None", VaryByCustom = "userName")]
public ActionResult Detail() //Controller
{
}
-------------------------------------
WEBCONFIG TARAFI
<!--caching-->
<caching>
    <outputCacheSettings>
        <outputCacheProfiles>
            <add name="MyCacheProfile" duration="600" location="Server" enabled="true"/>
        </outputCacheProfiles>
    </outputCacheSettings>
</caching>
<!--caching-->
-------------------------------------
şeklinde bir arada kullanılabilir

2 yorum:

  1. Asp.NET tarafı hangi cs ye yazılacak.

    YanıtlaSil
  2. Controller içerisinde Cache'i uygulamak istediğiniz metod üzerine aşağıdaki şekilde attribute'ü eklemeniz yeterli.

    [OutputCache(CacheProfile = "MyCacheProfile", VaryByParam = "strContentName", VaryByCustom = "userName")]

    YanıtlaSil