The "main" method in the ASP.Net MVC Project is which method runs before the pages load?

I have a project that is basically just an MVC project, because it gives intellisense for Razor views, and the library (Mvc.Mailer) depends on the HttpContext . Right now I need to load a page to run the constructor in my MvcApplication or Application_Start or Init .

Is there a way to load the main mvc app method or everything that is called before any page requests that do not require me to send a page load request?

+7
source share
4 answers

There is no method in ASP.NET that runs before the first access to your application.

The easiest way to fix this is to install AppFabric in your IIS and let it handle the automatic start of your services. It will “push” all configured services so that they always start and initialize.

+2
source

Accordingly: What is the root of the composition in the context of dependency injection?

You can use Global.asax.cs, which starts when the ASP.NET MVC project starts. I just checked this in my ASP.NET MVC project.

+2
source

Use the AutoStart function for AppFabric to preheat the AppPool to achieve what you want.

http://msdn.microsoft.com/en-us/library/ee677260.aspx

+1
source

override OnActionExecuting () of your controller. It is called every time the page is called.

0
source

All Articles