zoukankan      html  css  js  c++  java
  • Application和Session的例子

    %@ Page Language="C#" AutoEventWireup="true" CodeBehind="ApplicationTest.aspx.cs" Inherits="WebApplication1.ApplicationTest" %>
    
    <!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>Application和Session的例子</title>
    </head>
    <body>
        <%
    //如果没有设置名为"ApplicationCount"的Application
    int applicationCount=1;
    int sessionCount=1;
    if(Application["ApplicationCount"]==null)
    {
    Application["ApplicationCount"]=1;
    }
    else//否则取出该Session,并且在当前值上加1
    {
    applicationCount=(int)Application["ApplicationCount"]+1;
    Application["ApplicationCount"]=applicationCount;
    }
    //如果Session["SessionCount"]为空,即没有设置该名字的Session
    if(Session["SessionCount"]==null)
    {
    Session["SessionCount"]=1;
    }
    else
    {
    sessionCount=(int)Session["SessionCount"]+1;
    Session["SessionCount"]=sessionCount;
    }
    Response.Write("当前页面由Application记录到的被访问了"+applicationCount+"次<br/>");
    Response.Write("当前页面由Session记录到的被访问了"+sessionCount+"次<br/>");
    %>>
    </body>
    </html>
  • 相关阅读:
    07-汤姆猫
    快捷键
    UIImageView属性
    UIImagePickerController
    UIDatePicker
    并发编程简介
    区别值类型数据和引用类型数据
    用条件属性而不是#if
    选择is或者as操作符而不是做强制类型转换
    始终使用属性(Property),而不是字段(Data Member)
  • 原文地址:https://www.cnblogs.com/ai394495243/p/3335267.html
Copyright © 2011-2022 走看看