zoukankan      html  css  js  c++  java
  • asp.net页面缓存学习

      一个小练习,学习缓存,在页面建一个按键,打印出当前时间,

    在页面加上

    <%@ OutputCache  Duration="15"  VaryByParam ="none" %>这行代码,
    Duration是注明缓存页面的时间,15秒,VarByParam="none",这行代码的意思是,缓存不加任何条件,这样页面,在15秒内就不会再提交了!
    <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="WebForm8.aspx.cs" Inherits="WebApplication1.WebForm8" %>
    <%@ OutputCache  Duration="15"  VaryByParam ="none" %>
    
    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
    
    <html xmlns="http://www.w3.org/1999/xhtml">
    <head runat="server">
        <title></title>
    </head>
    <body>
        <form id="form1" runat="server">
        <div>
            <asp:Label ID="Label1" runat="server" Text=""></asp:Label> 
            <asp:Button ID="Button1" runat="server" Text="Button" onclick="Button1_Click" />
        </div>
        </form>
    </body>
    </html>

    后台代码

    public partial class WebForm8 : System.Web.UI.Page
        {
            protected void Page_Load(object sender, EventArgs e)
            {
    
            }
    
            protected void Button1_Click(object sender, EventArgs e)
            {
                DateTime  datetime = DateTime.Now;
    
                Label1.Text = datetime.ToString();
            }
        }

    缓存今天就学到这里,有时间再学吧

  • 相关阅读:
    ASP.NET在MVC控制器中获取Form表单值的方法
    MVC中几种常用ActionResult
    EF 配置MySQL
    HTTP 错误 403.6
    26个Jquery使用小技巧(转)
    Win2008R2配置WebDeploy(转)
    IIS快捷方式
    发布你的程序包到Nuget
    PostgreSQL recovery.conf恢复配置
    PostgreSQL 9.5 高可用、负载均衡和复制
  • 原文地址:https://www.cnblogs.com/xu3593/p/2965207.html
Copyright © 2011-2022 走看看