Mvc 3 outputcache varyByCustom扩展名

时间:2013-05-14 10:34:32

标签: asp.net-mvc-3 c#-4.0 outputcache

[OutputCache(Duration = 120, VaryByCustom = "siteId")]
public ActionResult Index()
{
     if(ConfigHelper.SiteId == 1)
        //massive logic here;
     else if(ConfigHelper.SiteId == 2)
        //massive logic here; 
     else if(ConfigHelper.SiteId == 3)
        //massive logic here; 
     return View(model);
}


 // from Config helper
 public static int SiteId
 {
      get { return GetAppSettingsValue<int>("SiteId", 0); }
 }

键入localhost时调用索引方法。是主页。 谁能知道如何从配置设置值获取varyByCustom?

0 个答案:

没有答案