⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 global.asax

📁 商务网站全部程序.很有借鉴意义
💻 ASAX
字号:
<%@ Import Namespace="system.data" %>
<%@ Import Namespace="system.data.oledb" %>
<script language="VB" runat="server">

    Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' 在应用程序启动时激发
		'application("time")=now
    End Sub
	
	Sub Application_AcquireRequestState(ByVal sender As Object, ByVal e As EventArgs)
        ' 应用程序为请求取得缓存时激发
		'response.Write("Acquiring request session state ...<br>")
    End Sub
	
	Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' 尝试对使用进行身份验证时激发 
		'response.Write("Authenticating request...<br>")		
    End Sub
	
	Sub Application_Authorizerequest(ByVal sender As Object, ByVal e As EventArgs)
        '应用程序批准HTTP请求时激发
		'response.Write("Authorize request...<br>")		
    End Sub
	
	Sub Application_Postrequesthandlerexecute(ByVal sender As Object, ByVal e As EventArgs)
        'HTTP处理程序处理请求后激发
		'response.Write("Post request handler execute...<br>")		
    End Sub
	
	Sub Application_Prerequesthandlerexecute(ByVal sender As Object, ByVal e As EventArgs)
        'HTTP处理程序处理请求前激发
		'response.Write("Pre request handler execute...<br>")		
    End Sub
	
	Sub Application_Presendrequestcontent(ByVal sender As Object, ByVal e As EventArgs)
        '如果请求额外的内容(查询字符串,表单变量等),则在这些内容收到之前激发
		'response.Write("Presend request content...<br>")		
    End Sub
	
	Sub Application_Presendrequestheaders(ByVal sender As Object, ByVal e As EventArgs)
        '收到请求报头之前激发
		'response.Write("Presend request headers...<br>")		
    End Sub
	
	Sub Application_Releaserequeststate(ByVal sender As Object, ByVal e As EventArgs)
        '应用程序释放请求的状态时激发
		'response.Write("Release request state...<br>")		
    End Sub
	
	Sub Application_ReleaserequestCache(ByVal sender As Object, ByVal e As EventArgs)
        '应用程序为请求解决缓存时激发
		'response.Write("Release request Cache...<br>")		
    End Sub
	
	Sub Application_UpdateRequestCahce(ByVal sender As Object, ByVal e As EventArgs)
        '应用程序为请求更新和释放缓存时激发
		'response.Write("Update Request Cahce...<br>")		
    End Sub	

    Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
        ' 在会话启动时激发
		'response.Write("session is starting...<br>")
		session.timeout=10
		application("online")=application("online")+1
		dim online as integer=executesql("select online from online","admin.mdb")
		if application("online") > online then 
		   executesql2("update online set online=" & application("online") & ",onlinedate=#" & now() & "#","admin.mdb")
		end if
		
		
		
		
		
    End Sub

    Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
        ' 在会话结束时激发
		application("online")=application("online")-1
		
    End Sub


    Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
        ' 在每个请求开始时激发
		'response.write("<b>process</b><p>")
		'response.write("BeginRequest request is starting...<br> ")
    End Sub



    Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
        ' 在发生错误时激发
		'response.write("Error...<br>")
		'response.end
    End Sub



    Sub Application_Endrequest(ByVal sender As Object, ByVal e As EventArgs)
        ' 在应用程序结束时激发
		'response.write("Application_End request is ending...<br>")
    End Sub
		   
		   
		   
	function executeSql(sql as string,database as string) as integer
          dim conn as new oledbconnection("provider=microsoft.jet.oledb.4.0; data source="+server.MapPath("data/" & database))
          dim objcmd as new oledbcommand(sql,conn)
          try
              objcmd.connection.open()
              return objcmd.executescalar()
          catch ex as exception
                 response.Write(ex.message)
          finally
                 objcmd.connection.close()
          end try
          end function
			
		 function executeSql2(sql as string,database as string)
              dim conn as new oledbconnection("provider=microsoft.jet.oledb.4.0; data source="+server.MapPath("data/" & database))
              dim objcmd as new oledbcommand(sql,conn)
         try
              objcmd.connection.open()
              return objcmd.executenonquery()
         catch ex as exception
              response.Write(ex.message)
         finally
             objcmd.connection.close()
         end try
         end function
</script>

⌨️ 快捷键说明

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