Why is global.asax missing from a Website Project

20,493

Solution 1

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.

Solution 2

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).

Solution 3

  1. You can add Global.asax to the website project and it will work fine.
  2. Global.asax is not added by default for web applications. If you have it, you can delete it without problems.

Be careful to include the .compiled files when deploying the website or else the events in Global.asax will not fire.

Share:
20,493
Dor Rotman
Author by

Dor Rotman

SOreadytohelp

Updated on September 11, 2020

Comments

  • Dor Rotman
    Dor Rotman almost 4 years

    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!