Метод GetVaryByCustomString не запускается

Метод GetVaryByCustomString не запускается, когда я помещаю в него точку останова.

Действие, которое я хочу кэшировать в зависимости от языка, выбранного пользователем:

[OutputCache(CacheProfile = "24HoursCache", VaryByCustom = "lang")]
public ActionResult MyAction()
{
    ...
}

Профиль кэша в файле Web.config:

<configuration>
    ...
    <system.web>
        ...
        <caching>
            <outputCacheSettings>
                <outputCacheProfiles>
                    <clear />
                    <add name="24HoursCache" duration="86400" location="Client" varyByParam="none" />
                </outputCacheProfiles>
            </outputCacheSettings>
        </caching>
    </system.web>
    ...
</configuration>

И в файле Global.asax.cs:

public override string GetVaryByCustomString(HttpContext context, string value)
{
    if (value.ToLower() == "lang")
    {
        return Thread.CurrentThread.CurrentUICulture.Name;
    }

    return base.GetVaryByCustomString(context, value);
}

Любая помощь будет оценена, спасибо!

1 ответ

На самом деле местоположение должно быть установлено на "Сервер", а не "Клиент".

<configuration>
        ...
        <system.web>
            ...
            <caching>
                <outputCacheSettings>
                    <outputCacheProfiles>
                        <clear />
                        <add name="24HoursCache" duration="86400" location="Server" varyByParam="none" />
                    </outputCacheProfiles>
                </outputCacheSettings>
            </caching>
        </system.web>
        ...
    </configuration>

И это работает, фу!

Другие вопросы по тегам