0

The problem is that in my Azure Mobile Services project the Application_Start method is never called on the server.

What confuses me is the fact that the start-up project, which I downloded from the dashboard of the Mobile Service on the portal, isn't working neither. Locally everything works as expected but not after publishing.

What am I doing wrong?

core
  • 851
  • 1
  • 8
  • 28
  • After you publish, do you get a blue smiley face page that says that you successfully published your service? If not, make sure that you deployed your server project, see instructions here: https://azure.microsoft.com/en-us/documentation/articles/mobile-services-dotnet-backend-windows-store-dotnet-get-started/ – lindydonna Oct 06 '15 at 04:18
  • Yes I get the blue smiley. In principle the service is running, except of calling the `Application_Start` method in `Global.asax.cs`. For example throwing an exception in the method leads also to the blue smiley. – core Oct 06 '15 at 16:02
  • What happens when you send a request to the service? You should then get a 500 error, which will also show up in the Logs tab of the Azure Portal. – lindydonna Oct 06 '15 at 17:56
  • No, the service is running correctly, except of doing the whole bootstrapping stuff like initializing the DI-container which I want to do in the `Application_Start` method. In this answer: http://stackoverflow.com/a/16687625/1517915 it is written that `Application_Start` is ignored by the Azure runtime. But where to bootstrap the application? – core Oct 06 '15 at 18:22

1 Answers1

1

Your site doesn't run exactly the same when hosted in Azure Mobile Services, since the hosted service does additional things to ensure that everything is running correctly.

In particular, Application_Start is one of the things that is instrumented by your service. We recommend that you put your initialization code in WebApiConfig.Register() instead, this will definitely be call, and is where Mobile Services expects your initialization code to be.

lindydonna
  • 3,874
  • 17
  • 26