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 Classes Global.asa:


In ASP.NET, there isn't a file called global.asa. The global.asa file was used in classic ASP (Active Server Pages) for application-level events and settings. However, in ASP.NET, you use the Global.asax file for similar purposes.

Global.asax:

The Global.asax file is an optional file that contains code for responding to application-level events raised by ASP.NET or by HttpModules. It serves as a central location for handling application-level events and can contain code for application startup, shutdown, session start, session end, error handling, etc.

Example:

Here's a simple example demonstrating how you might use Global.asax:

Example

<%@ Application Language="C#" %>

<script runat="server">

void Application_Start(object sender, EventArgs e)
{
// Code that runs on application startup
Application["AppStartTime"] = DateTime.Now;
}

void Application_End(object sender, EventArgs e)
{
// Code that runs on application shutdown
}

void Session_Start(object sender, EventArgs e)
{
// Code that runs when a new session is started
}

void Session_End(object sender, EventArgs e)
{
// Code that runs when a session ends
}

void Application_Error(object sender, EventArgs e)
{
// Code that runs when an unhandled error occurs
}

</script>

In this example:

You can add code to these event handlers to perform tasks specific to your application, such as initializing application-wide resources, logging events, handling errors, etc.

Remember, Global.asax is a powerful file for managing application-level events and behavior in ASP.NET applications.


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