Set Page Output Cache VaryByCustom value programmatically

Posted by Chris Marisic on Stack Overflow See other posts from Stack Overflow or by Chris Marisic
Published on 2010-04-15T18:22:42Z Indexed on 2010/04/27 17:13 UTC
Read the original article Hit count: 212

Filed under:
|
|
|

I want to use an Enum value for the types of VaryByCustom parameters I will support, is it possible to do this?

I tried setting it in the page itself

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

But this returned the entire literal string "<%=VaryByCustomType.IsAuthenticated.ToString(); %>" inside my global.asax is there any way to do this either on the page itself or from the codebehind? Or is this just something I have to accept is purely magic strings and nothing I can do to add type safety to it?

© Stack Overflow or respective owner

Related posts about .NET

Related posts about outputcache