VaryByParam似乎不起作用

时间:2012-06-12 15:48:51

标签: asp.net webforms

我在后面的代码中有一个带有以下内容的网络表单:

Response.Clear();
Response.ContentType = "application/json; charset=utf-8";

int _pGID = base.GetParamAsInt("PGID");

if (_pGID > 0)
{
  Response.Write(...);
}
else
{
  Response.Write(...);
}

Response.End();

以下标记:

<%@ Page Language="C#" AutoEventWireup="true" CodeFile="PG.aspx.cs" 
    Inherits="PG" %>

<%@ OutputCache Duration="60" VaryByParam="PGID" %>

问题是每次请求页面时都会触发page_load事件,即使QueryString的'PGID'参数相同也是如此。

我遗漏了有关如何使用VaryByParam属性的内容?

1 个答案:

答案 0 :(得分:0)

从代码中休息并进行更多测试后,似乎对Response.End()的调用导致了问题。从一些文章中,Response.Flush()也会导致同样的问题。

相关问题