📄 default2.aspx.cs
字号:
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
public partial class Default2 : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
object objectHelper = new object();
lock (objectHelper)
{
if (Application["percount"] == null)
{
CreateApplication();
}
else
{
bool isIn = false;
DataTable dt = (DataTable)Application["percount"];
for (int i = 0; i < dt.Rows.Count; i++)
{
if (GetIP() == dt.Rows[i]["perIp"].ToString())
isIn = true;
}
if (!isIn)
{
}
}
}
}
protected void CreateApplication()
{
DataTable dt = new DataTable();
dt.Columns.Add("perIp");
DataRow dr = dt.NewRow();
dr["perIp"] = GetIP();
dt.Rows.Add(dr);
Application["percount"] = dt;
}
protected string GetIP()
{
string result = String.Empty;
result = HttpContext.Current.Request.ServerVariables["HTTP_X_FORWARDED_FOR"];
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.ServerVariables["REMOTE_ADDR"];
}
if (null == result || result == String.Empty)
{
result = HttpContext.Current.Request.UserHostAddress;
}
return result;
}
protected void CountApplication(char operation)
{
switch (operation)
{
case '+':
Application["percount"] = Convert.ToInt32(Application["percount"]) + 1;
break;
case '-':
Application["percount"] = Convert.ToInt32(Application["percount"]) - 1;
break;
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -