7

サポートする VaryByCustom パラメータのタイプに Enum 値を使用したいのですが、可能ですか?

ページ自体に設定してみました

<%@ OutputCache Duration="600" VaryByParam="none" 
            VaryByCustom='<%=VaryByCustomType.IsAuthenticated.ToString(); %>' %>

しかし、これは"<%=VaryByCustomType.IsAuthenticated.ToString(); %>"私の内部のリテラル文字列全体を返しglobal.asaxました。ページ自体またはコードビハインドからこれを行う方法はありますか? それとも、これは純粋に魔法の文字列であり、型の安全性を追加するために私ができることは何もないことを受け入れなければならないのですか?

4

1 に答える 1

8

Instead of using the @Outputcache directive, try doing it with code in the page. e.g.

void Page_Init() {
    var outputCacheSettings = new OutputCacheParameters() {
        Duration = 600,
        VaryByCustom = VaryByCustomType.IsAuthenticated.ToString()
    };
    InitOutputCache(outputCacheSettings); 
}
于 2010-04-27T20:02:44.203 に答える