sessionservice1.asmx

来自「asp做的新闻系统」· ASMX 代码 · 共 34 行

ASMX
34
字号
<%@ WebService Language="C#" Class="SessionService1" %>

using System;
using System.Web.Services;

public class SessionService1 : WebService {

   [ WebMethod(EnableSession=true) ]
   public String UpdateHitCounter() {

        if (Session["HitCounter"] == null) {
            Session["HitCounter"] = 1;
        }
        else {
            Session["HitCounter"] = ((int) Session["HitCounter"]) + 1;
        }

        return "这是您第 " + Session["HitCounter"].ToString() + " 次访问该服务。";
   }

   [ WebMethod(EnableSession=false)]
   public String UpdateAppCounter() {

        if (Application["HitCounter"] == null) {
            Application["HitCounter"] = 1;
        }
        else {
            Application["HitCounter"] = ((int) Application["HitCounter"]) + 1;
        }

        return "这是您第 " + Application["HitCounter"].ToString() + " 次访问该服务。";
   }
}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?