Protected Sub Application_BeginRequest(sender As [Object], e As EventArgs) 'SQL防注入 Dim Sql_1 As String = "exec ¦insert+ ¦select+ ¦delete ¦update ¦count ¦chr ¦mid ¦master+ ¦truncate ¦char ¦declare ¦drop+ ¦drop+table ¦creat+ ¦creat+table" Dim Sql_2 As String = "exec+ ¦insert+ ¦delete+ ¦update+ ¦count( ¦count+ ¦chr+ ¦+mid( ¦+mid+ ¦+master+ ¦truncate+ ¦char+ ¦+char( ¦declare+ ¦drop+ ¦creat+ ¦drop+table ¦creat+table" Dim sql_c As String() = Sql_1.Split("¦") Dim sql_c1 As String() = Sql_2.Split("¦") ' If Not (Request.QueryString Is Nothing) Then Dim sl As String For Each sl In sql_c If Request.QueryString.ToString().ToLower().IndexOf(sl.Trim()) >= 0 Then Response.Write("警告!你的IP已经被记录!") ' Response.Write(sl) Response.Write(Request.QueryString.ToString()) Response.End() Exit ForEach End If Next sl End If If Request.Form.Count > 0 Then Dim s1 As String = Request.ServerVariables("SERVER_NAME").Trim() '服务器名称 If Not (Request.ServerVariables("HTTP_REFERER") Is Nothing) Then Dim s2 As String = Request.ServerVariables("HTTP_REFERER").Trim() 'http接收的名称 Dim s3 As String = "" If s1.Length > s2.Length - 7 Then s3 = s2.Substring(7) Else s3 = s2.Substring(7, s1.Length) End If If s3 <> s1 Then Response.Write("你的IP已被记录!警告!") ' Response.End() End If End If End If End Sub