I'm developing an application using MVC6.
I noticed that the Global.asax
file disappeared by default there is startup.cs
file that calls the config. My question is how do I grab the Application_Start
event method ?
Do I still need the Global.asax
?
Why has it been removed by default ?
We know that Global. asax is an optional file to handle Application level event in ASP.NET application.
They defined methods for a single class, application class. They are optional, but a web application has no more than one global. asax file.
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). Save this answer.
The Global. asax file is a special file that contains event handlers for ASP.NET application lifecycle events. The route table is created during the Application Start event. The file in Listing 1 contains the default Global.
Global.asax is only present when there is a reason to hook into it. The default MVC6 project has no hooks into it, therefore it doesn't provide one. Just add new item, global.asax
I should also suggest, that I would avoid creating a global.asax unless you need absolutely need it. People tend to reach for Application_Start or Session_Start first when there are probably better places to do what you need to do. Consider creating an OWIN module, or consider adding your own Startup module.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With