📄 intrincs.asmx
字号:
<%@ WebService Language="C#" Class="IntrinsicsSample" %>
using System;
using System.Web.Services;
public class IntrinsicsSample : WebService {
//更新Session计数器的方法
[ WebMethod(EnableSession=true) ]
public String UpdateSession() {
if (Session["SessionCounter"] == null) {
Session["SessionCounter"] = 1;
}
else {
//用户请求一次服务,计数器加一
Session["SessionCounter"] = ((int) Session["SessionCounter"]) + 1;
}
return "您请求了此项服务" + Session["SessionCounter"].ToString() + "次";
}
//更新Application计数器的方法
[ WebMethod(EnableSession=false)]
public String UpdateApplication() {
if (Application["AppCounter"] == null) {
Application["AppCounter"] = 1;
}
else {
//没次服务被请求后,计数器加一
Application["AppCounter"] = ((int) Application["AppCounter"]) + 1;
}
return "此项服务已经被请求了" + Application["HitCounter"].ToString() + "次";
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -