Home Python C Language C ++ HTML 5 CSS Javascript Java Kotlin SQL DJango Bootstrap React.js R C# PHP ASP.Net Numpy Dart Pandas Digital Marketing

ASP.NET Reference Application:


In ASP.NET, "Application" refers to an object that represents the web application itself. It provides a way to store and access data that is shared among all users of the application. This shared data persists for the duration of the application's lifetime.

Here's a simple explanation with an example:

Example

Public Class Global_asax
Inherits System.Web.HttpApplication

Sub Application_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application startup
Application("Counter") = 0 ' Initialize a counter variable in the Application object
End Sub

Sub Session_Start(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a new session is started
End Sub

Sub Application_BeginRequest(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs at the beginning of each request
End Sub

Sub Application_EndRequest(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs at the end of each request
End Sub

Sub Application_AuthenticateRequest(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when an authentication request is made
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_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs when a session ends
End Sub

Sub Application_End(ByVal sender As Object, ByVal e As EventArgs)
' Code that runs on application shutdown
End Sub

End Class

In this example:

You can access and modify data stored in the Application object throughout your application's code. For example:

Example

Sub IncrementCounter()
' Increment the counter variable stored in the Application object
Application("Counter") = CInt(Application("Counter")) + 1
End Sub

This code increments the counter variable stored in the Application object by 1. You can call this method from anywhere in your application to update the counter value.


Advertisement
Advertisement





Q3 Schools : India


Online Complier

HTML 5

Python

java

C++

C

JavaScript

Website Development

HTML

CSS

JavaScript

Python

SQL

Campus Learning

C

C#

java