// TODO: 以后白名单里面可以配置更大的数量 protected void Session_Start(Object sender, EventArgs e) { OpacApplication app = null; try { app = (OpacApplication)Application["app"]; if (app == null) { throw new Exception("app == null while Session_Start(). global error info : " + (string)Application["errorinfo"]); } string strClientIP = HttpContext.Current.Request.UserHostAddress; // 增量计数 if (app != null) { long v = app.IpTable.IncIpCount(strClientIP, 1); if (v >= app.IpTable.MAX_SESSIONS_PER_IP) { app.IpTable.IncIpCount(strClientIP, -1); Session.Abandon(); return; } } SessionInfo sessioninfo = new SessionInfo(app); sessioninfo.ClientIP = strClientIP; Session["sessioninfo"] = sessioninfo; // throw new Exception("test exception"); app.IncSesstionCounter(Request.UserHostAddress); } catch (Exception ex) { string strErrorText = "Session_Start阶段出现异常: " + ExceptionUtil.GetDebugText(ex); OpacApplication.WriteWindowsLog(strErrorText); if (app != null) { app.GlobalErrorInfo = strErrorText; } else { Application["errorinfo"] = strErrorText; } } }