zoukankan      html  css  js  c++  java
  • asp.net学习笔记·Cookie

    •        Cookie是和站点相关的,每次向服务器请求的时候,除了发送表单参数外,还会将和站点相关的Cookie值都提交给服务器,并且将服务器返回的Cookie更新到浏览器Cookie中去,且这是强制性的;
    •      Cookie的生命周期可以设置;
    •        缺点:Cookie不能存储过多的数据;
    •        网站优化案例:网站图片服务器和主站服务器域名不一样,降低提交Cookie消耗的流量;
    •        变量自增代码示例:
    • using System;
      using System.Collections.Generic;
      using System.Linq;
      using System.Web;
      using System.Web.UI;
      using System.Web.UI.WebControls;
      
      public partial class 变量自增 : System.Web.UI.Page
      {
          private int a = 0;
          protected void Page_Load(object sender, EventArgs e)
          {
              if (IsPostBack)
              {
                  Response.SetCookie(new HttpCookie("num", "0"));
      //新建HttpCookie对象
                  this.Label1.Text = "0";
              }
          }
          protected void Button1_Click(object sender, EventArgs e)
          {
                int.TryParse(Request.Cookies["num"].Value, out a);
                  a++;
                  Response.SetCookie(new HttpCookie("num", a.ToString()));
                  this.Label1.Text = a.ToString();
             
          }
      }
      

        

  • 相关阅读:
    node.js
    重学css
    MongoDB
    改写radio样式
    js系统总结
    vue+koa2商城实战学习笔记
    在Linux上配置unixODBC和FreeTDS访问MS SQL Server
    ASP.NET中文件上传下载方法集合
    SQL SERVER 分页查询存储过程
    Delphi7调用C#写的Webservice
  • 原文地址:https://www.cnblogs.com/xuhongfei/p/2829387.html
Copyright © 2011-2022 走看看