Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Why is global.asax missing from a Website Project

A couple of questions regarding the role of global.asax:

  1. Why is it not included in the Website Project in Visual Studio? Are there other ways of achieving the same functionality without this file?

  2. If I would create a Web Application project, as far as I remember, a global.asax file would be created. If I were to delete it, would the project run?

I tried to look for some explanation regarding the global.asax compilation but didn't find any info about this.. would appreciate help/links. :)

Thanks!

like image 694
Dor Rotman Avatar asked Mar 25 '09 17:03

Dor Rotman


People also ask

Where is my global ASAX file?

The Global. asax, also known as the ASP.NET application file, is located in the root directory of an ASP.NET application. This file contains code that is executed in response to application-level and session-level events raised by ASP.NET or by HTTP modules.

How do I add global ASAX Cs to my website?

How to add global. asax file: Select Website >>Add New Item (or Project >> Add New Item if you're using the Visual Studio web project model) and choose the Global Application Class template. After you have added the global.

Is global ASAX mandatory?

Global. asax is an optional file which is used to handling higher level application events such as Application_Start, Application_End, Session_Start, Session_End etc.


2 Answers

An ASP.NET site can run without the global.asax file. Here is a question which talks about alternatives of global.asax file.

Even if you delete a global.asax file your site will work.

like image 84
Shoban Avatar answered Oct 17 '22 02:10

Shoban


Globax.asax is not required by ASP.NET for a website to run. It is, however, very useful for application-level functionality (like unhandled exception logging).

like image 37
Andrew Hare Avatar answered Oct 17 '22 02:10

Andrew Hare