Search code examples
c#.netprogram-entry-point

Why doesn't C# .Net Framework Web Form Application have a Main function, or Program.cs


I was following some tutorials and created a new C# .Net Framework 4.6 Application as a web form type. When working on the project I noticed it doesn't have a Main Function to add logic too, it also doesn't have a program.cs, yet it is able to build fine. Why is that, I was under the impression that all C# programs need a main function to start as there entry point, and have seen multiple resources on the web stating that(https://www.c-sharpcorner.com/blogs/main-method-in-c-sharp, https://www.completecsharptutorial.com/basic/main-method.php).

If we don't need it what is replacing it, and serving as the code entry point. I also noticed that there is no program.cs what is the reason for this. I have been researching but I find the answers posted very contradictory to what is actually in the code.


Solution

  • Because in the old (.NET Framework) it runs in process - the startup code is for some reason that are MOSTLY historical (ASP pre .NET) in a file GLOBAL.ASAX

    What is the purpose of global.asax in asp.net

    Again, this really goes back to asp.net mvc following up on the concepts of asp (pre .net). It is rectified in the Core versions where basically a program starts for the application.