아래의 aspx 및 코드 배후에서 출력 캐싱을 프로그래밍 방식으로 사용할 수있는 경우 (코드 숨김에서 사용 가능) 작동하지 않으며 문제가 있습니까?ASP.NET 프로그래밍 방식으로 출력 캐싱이 작동하지 않습니다 -> 왜?
영문 :
<%@ Page Language="C#" AutoEventWireup="true" Inherits="ProgrammaticOutputCaching"
CodeBehind="ProgrammaticOutputCaching.aspx.cs" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblDate" runat="server" Font-Bold="False" Font-Names="Verdana" Font-Size="XX-Large"></asp:Label><br />
<br />
<asp:Button ID="Button1" runat="server" Text="Refresh" />
</div>
</form>
</body>
</html>
코드 숨김 문제가없는 출력 캐싱에 대한 페이지 지시문
protected void Page_Load(object sender, EventArgs e)
{
Response.Cache.SetCacheability(HttpCacheability.Public);
// Use the cached copy of this page for the next 60 seconds.
Response.Cache.SetExpires(DateTime.Now.AddSeconds(60));
//Response.Cache.VaryByParams.IgnoreParams = true;
// This additional line ensures that the browser can't
// invalidate the page when the user clicks the Refresh button
// (which some rogue browsers attempt to do).
Response.Cache.SetValidUntilExpires(true);
lblDate.Text = "The time is now:<br>" + DateTime.Now.ToString();
}
:
:이
영문을 의미 691,363,210
<%@ Page Language="C#" AutoEventWireup="true" Inherits="OutputCaching" CodeBehind="OutputCaching.aspx.cs" %>
<%@ OutputCache Duration="60" VaryByParam="Name;Age" Location="Server" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.1//EN" "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head runat="server">
<title>Untitled Page</title>
</head>
<body>
<form id="form1" runat="server">
<div>
<asp:Label ID="lblDate" runat="server" Font-Bold="False" Font-Names="Verdana"
Font-Size="XX-Large"></asp:Label>
<br />
<br />
<asp:Button ID="Button1" runat="server" Text="Refresh" />
</div>
</form>
</body>
</html>
뒤에
코드 :
protected void Page_Load(object sender, EventArgs e)
{
lblDate.Text = "The time is now:<br>";
lblDate.Text += DateTime.Now.ToString();
}
때문에 문제가 프로그래밍에 대해 무엇인가? 이 모든 방법이 할
"작동하지 않는다"고 할 때, 날짜가 페이지에서 항상 업데이트된다는 것을 의미합니까? 아니면 다른 문제입니까? 예외입니까? –
@ Graham Clark hi : 날짜가 항상 페이지에서 업데이트된다는 것을 의미합니다 (예 : 캐시되지 않습니다). – MoonLight
또한 outputCaching에 대한 페이지 지시문에는 아무런 문제가 없습니다 /하지만 prorammatically!/내가 영향을 받고 machine.config 또는 루트 web.config 또는 응용 프로그램 web.config에서 뭔가를 변경해야합니까? – MoonLight