Where is the Global.asax.cs file?
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.
Introduction
In classic ASP.NET applications on .NET Framework, Global.asax.cs is usually located in the root of the web application, next to Global.asax. It contains the code-behind for application-level events such as Application_Start, but whether you actually have the file depends on the project type.
The Typical Location
In an ASP.NET Web Application project, the usual structure is:
So the short answer is: look in the application root, not in App_Code, Controllers, or some hidden framework folder.
The Global.asax file contains the application directive, and Global.asax.cs contains the backing class that inherits from HttpApplication.
What the Files Usually Look Like
A typical Global.asax file looks like this:
And the code-behind might look like this:
That is why the file is important: it is the place where classic ASP.NET app-wide startup and lifecycle hooks often live.
Why You Might Not See It
There are several cases where developers search for Global.asax.cs and do not find it.
First, some projects use Visual Basic instead, which means the companion file is Global.asax.vb.
Second, older Website-style projects can behave differently from Web Application projects. In some cases, the code may be inline or structured differently from the explicit code-behind pattern you expect.
Third, ASP.NET Core does not use Global.asax at all. If the project is ASP.NET Core, looking for Global.asax.cs is a category error. Startup behavior moved into Program.cs, Startup.cs in older Core templates, and the host-building pipeline.
How to Add It If Missing
In a classic ASP.NET project, Visual Studio can add it through the Global Application Class template. Once added, it appears in the project root.
If the file exists on disk but does not appear where you expect in the IDE, check whether the project is excluding files or whether you are looking at the deployed site rather than the source project.
What Usually Belongs There
Typical responsibilities include:
- '
Application_Start' - '
Application_End' - global error hooks
- route registration in older MVC projects
- app-wide initialization code
That said, not every project should put large amounts of logic there. Global.asax.cs is an application lifecycle hook file, not a general dumping ground.
Visual Studio and Solution Explorer
In Visual Studio, Global.asax.cs is often nested under Global.asax in Solution Explorer rather than displayed as a completely separate top-level item. That small UI detail causes confusion for people who expect to see two flat files listed side by side even though both exist on disk in the same root folder.
Common Pitfalls
- Looking for
Global.asax.csin an ASP.NET Core project, where it does not exist. - Assuming every classic ASP.NET project uses a C# code-behind file instead of inline code or
Global.asax.vb. - Searching outside the application root even though the file normally lives beside
Global.asax. - Confusing Website and Web Application project structures.
- Putting unrelated business logic into
Global.asax.csjust because it runs early in the app lifecycle.
Summary
- In classic ASP.NET on .NET Framework,
Global.asax.csis usually in the application root next toGlobal.asax. - It contains the code-behind for application lifecycle events.
- Some projects use
Global.asax.vbinstead, and some Website projects structure things differently. - ASP.NET Core does not use
Global.asax.csat all. - If the file is missing, verify the project type before assuming something is wrong.
Related reading
- Which built-in .NET exceptions can I throw from my application?
- Which is generally best to use — StringComparison.OrdinalIgnoreCase or StringComparison.InvariantCultureIgnoreCase?
- Which members of .NET's ConcurrentDictionary are thread-safe?
- Which method performs better .Any vs .Count 0?
- Which .NET Dependency Injection frameworks are worth looking into?
- Which sorting algorithm is used by .NET's Array.Sort method?
- Which way is preferred when doing asynchronous WCF calls?
- Why am I getting this error No mapping specified for the following EntitySet/AssociationSet - Entity1?

OOD Fundamentals
Master object-oriented design from first principles, SOLID, design patterns, and classic interview problems with hands-on coding.
View the courseTrack what you have practised
A free account saves your progress, solutions and study plan across every problem on Codemia.
Interview Questions practice on Codemia
Over 8,000 real interview questions from top companies, searchable by company and role.