WebActivator allows us to execute a code long before application start-up. There may be requirements when you need to load external assemblies or instantiate a particular object before the application start up. You need to make sure some codes execute before the codes inside the App_Start folder and the global.asax file. To do this WebActivator should be used.
You can add the WebActivator package using NuGet.
Let us consider an example in an MVC application in which we want to call a method of a class before the execution of the application. To do this follow the steps below:
- Attribute the class with WebActivator
- Pass the type of the class
- Pass the name of the method to be executed