Merhaba arkadaşlar bu yazımda sizinle birlikte routing kullandığımız bir sitede sayfamızı ön bellekleyeceğiz.
Daha eskiden http://localhost/sayfa.aspx?id=1 şeklinde id değerine göre sayfamızı ön bellekliyorduk.Şimdi olay biraz değişti artık http://localhost/icerikler/yeni-icerik-burada.html şeklinde sayfalarımız var Url Routing ile nasıl ön bellekleyeceğiz.
Global.asax içerisine aşağıdaki kodumuzu yerlestiriyoruz.sayfamıza ise
VaryByCustom
ekledik
Code:
<%@ OutputCache Duration="15" VaryByParam="None" VaryByCustom="productIdInUrl" %>
Code:
public override string GetVaryByCustomString(HttpContext context,
string arg)
{
if(arg == "productIdInUrl")
{
return context.Request.RawUrl;
}
return base.GetVaryByCustomString(context, arg);
}
Hiç yorum yok:
Yorum Gönder