ASP.Net/Page/OutputCache — различия между версиями

Материал из .Net Framework эксперт
Перейти к: навигация, поиск
м (1 версия)
 
м (1 версия)
 
(нет различий)

Текущая версия на 11:53, 26 мая 2010

Asp cache by browser

<%@Page Language="C#"%>
<%@OutputCache Duration="10" VaryByParam="none" VaryByCustom="browser" %>
<html>
<body>
<asp:panel id="pnlTest" runat="server">
  Page executed: <% = DateTime.Now %><br />
</asp:panel>
</body>
</html>



Cache duration (C#)

<%@Page Language="C#"%>
<%@OutputCache Duration="10" VaryByParam="none" %>
<html>
<body>
<asp:panel id="pnlTest" runat="server">
  Page executed: <% = DateTime.Now %>
</asp:panel>
</body>
</html>



Get server time (C#)

<%@ OutputCache Duration="60" VaryByParam="none" %>
<script  language="c#" runat = "server">
  string ServerTime()
  {
    return System.DateTime.Now.ToLongTimeString();
  }
</script>
The time on your web server is : <%=ServerTime() %>



Using the OutputCache Directive (VB.net)

<%@ Page Language=VB Debug=true %>
<%@ OutputCache Duration=30 VaryByParam=none%>
<script runat=server>
Sub Page_Load(ByVal Sender as Object, ByVal E as EventArgs)
    lbl1.Text = "The current time on the server is " & TimeOfDay()
End Sub
</script>
<HTML>
<HEAD>
<TITLE>Using the OutputCache Directive</TITLE>
</HEAD>
<Body LEFTMARGIN="40">
<form runat="server">
<asp:label id="lbl1" runat="server"/>
</Form>
</BODY>
</HTML>