web 2.0

ASP.NET(vb.net) & Global.asax

ASP.NET(vb.net) & Global.asax - Global.asax : The Global.asax file, also known as the ASP.NET application file, is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules. The Global.asax file resides in the root directory of an ASP.NET-based application. At run time, Global.asax is parsed and compiled into a dynamically generated .NET Framework class derived from the HttpApplicationbase class. The Global.asax file itself is configured so that any direct URL request for it is automatically rejected; external users cannot download or view the code written within it.

ShotDev Focus:
- ASP.NET(vb.net) & Global.asax

Example

Global.asax

<%@ Application Language="VB" %>

<script runat="server">

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
Application("OnlineNow") = 0
End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
Application("OnlineNow") = Nothing
End Sub

Sub Application_Error(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an unhandled error occurs
End Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
Application.Lock()
Application("OnlineNow") = Application("OnlineNow") + 1
Application.UnLock()
End Sub

Sub Session_End(ByVal sender As Object, ByVal e As EventArgs)
Application.Lock()
Application("OnlineNow") = Application("OnlineNow") - 1
Application.UnLock()
End Sub

</script>

AspNetGlobal.aspx

<%@ Page Language="VB" %>
<script runat="server">
Sub Page_Load(sender As Object, e As EventArgs)
Me.lblText.Text = Application("OnlineNow") & " Online"
End Sub
</script>
<html>
<head>
<title>ShotDev.Com Tutorial</title>
</head>
<body>
<form id="form1" runat="server">
<asp:Label id="lblText" runat="server"></asp:Label><br />
</form>
</body>
</html>

Screenshot

ASP.NET(vb.net) & Global.asax
.
.
.
Download this script.
Download
.
.
.
Property & Method

ASP.NET(vb.net) Application_Start() - Global.asax
ASP.NET(vb.net) Application_End - Global.asax
ASP.NET(vb.net) Application.Lock() - Global.asax
ASP.NET(vb.net) Application.UnLock() - Global.asax
ASP.NET(vb.net) Session_Start() - Global.asax
ASP.NET(vb.net) Session_End() - Global.asax
ASP.NET(vb.net) Application_Error() - Global.asax
ASP.NET(vb.net) Application_BeginRequest() - Global.asax
ASP.NET(vb.net) Application_AuthenticateRequest() - Global.asax

1 Star2 Stars3 Stars4 Stars5 Stars6 Stars7 Stars8 Stars9 Stars10 Stars (No Ratings Yet)
Loading ... Loading ...

Leave a Reply

You must be logged in to post a comment.