ASP.NET - caching page substitution and output (donut) - how to pass a user argument to the delegate HttpResponseSubstitutionCallback

I would like to use the donut cache override function.

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 an additional parameter to the callback function next to the HttpContext.
so the question is:
How do I pass an additional argument to the GetTime callback?
for example, 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");
}
+5
source share
2 answers

, , , -, , - , .

+2

, , . GetTime HttpContext.

+1

All Articles