0

我在后面的代码中有一个 Web 表单,其中包含以下内容:

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 属性的信息?

4

1 回答 1

0

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

于 2012-06-13T09:39:41.063 回答