简体   繁体   中英

Application_Start not firing in ASP.NET MVC app

I've got an ASP.NET MVC app where the Application_Start event appears to not be firing. The symptoms are that an NLog log statement in that handler does not generate a log entry, and none of my routes get populated (so all my requests for controller actions return a 404).

Static files on the server (eg, favicon.ico) are served correctly.

I have log statements in Application_BeginRequest and Application_EndRequest. Those do generate log entries, both for the controller methods and the static files, so I feel pretty confident the app pool is configured correctly.

The problem shows up on our staging server, but not my local machine or our dev server.

Any idea what would cause this?

It ended up being a combination of things. The root cause was inconsistent versions of DLL's, and I solved that by configuring the project to copy the problem assemblies to my bin folder. On top of that, there was some code in Application_Error that was preventing the actual exception from being shown.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM