Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpApplication.Application_Start not firing after upgrade to Web API 2

I upgraded an application to Web Api 2 and the Application_Start would not fire post upgrade running on IIS Express. I did follow the official upgrade path at http://www.asp.net/mvc/tutorials/mvc-5/how-to-upgrade-an-aspnet-mvc-4-and-web-api-project-to-aspnet-mvc-5-and-web-api-2 and have triple checked my settings.

The application uses StructureMap MVC 4 to inject dependencies. So WebActivator's PreApplicationStartMethod gets fired and the dependency resolver gets set correctly. After that, no other execution can be traced. I have enabled Edit and Continue and yet break point at the start of Application_Start is not hit.

Here's all that I've tried: a. Disable PreApplicationStartMethod and run the app b. Change the compile settings of the Global.asax and the code behind c. Create another WebApi2 project with similar structure and set up minus the actual code and that works fine

I have cleaned and run the app; also have cleaned the Temp ASP.NET folder

Appreciate the help towards resolving this issue.

like image 946
paneer Avatar asked Oct 30 '13 20:10

paneer


2 Answers

Put a Debugger.Break(); statement in your Application_Start, and then do an iisreset or recycle your app pool, then hit F5. A Just in time debugger window should appear if a breakpoint doesn't cut it.

like image 43
demoncodemonkey Avatar answered Oct 21 '22 17:10

demoncodemonkey


Your debugger attaches after your application is started, therefor you won't hit any breakpoints in your application start method. A workaround is to cause your webserver to restart while you're attached to the process:

Simply edit your web.config (just add a space) and save it, this will make your http application restart.

like image 161
user2674389 Avatar answered Oct 21 '22 17:10

user2674389