ASP .NET - Substitution and page output (donut) caching - How to pass custom argument to HttpRespons

Posted by zzare on Stack Overflow See other posts from Stack Overflow or by zzare
Published on 2010-03-28T13:14:39Z Indexed on 2010/03/28 13:23 UTC
Read the original article Hit count: 479

Filed under:
|
|

I would like to use substitution feature of donut caching.

public static string GetTime(HttpContext context)
{
    return DateTime.Now.ToString("T");
}

...

The cached time is: <%= DateTime.Now.ToString("T") %>
<hr />
The substitution time is:
<% Response.WriteSubstitution(GetTime); %>

...But I would like to pass additional parameter to callback function beside HttpContext.
so the question is:
How to pass additional argument to GetTime callback?
for instance, something like this:

public static string GetTime(HttpContext context, int newArgument)
{
    // i'd like to get sth from DB by newArgument
    // return data depending on the db values

    // ... this example is too simple for my usage
    if (newArgument == 1)
        return "";
    else
        return DateTime.Now.ToString("T");
}

© Stack Overflow or respective owner

Related posts about ASP.NET

Related posts about c#