小编zza*_*are的帖子

ASP .NET - 替换和页面输出(圆环)缓存 - 如何将自定义参数传递给HttpResponseSubstitutionCallback委托

我想使用甜甜圈缓存的替换功能.

public static string GetTime(HttpContext context)
{
    return DateTime.Now.ToString("T");
}
Run Code Online (Sandbox Code Playgroud)

...

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

...但我想在HttpContext旁边传递额外的参数到回调函数.
所以问题是:
如何将额外的参数传递给GetTime回调?
例如,像这样:

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");
}
Run Code Online (Sandbox Code Playgroud)

c# asp.net donut-caching

5
推荐指数
1
解决办法
1046
查看次数

标签 统计

asp.net ×1

c# ×1

donut-caching ×1