I use Ninject for my app.
public class Global : NinjectHttpApplication
On Application started I call:
protected override void OnApplicationStarted()
...
if (RoleEnvironment.IsAvailable)
{
RoleEnvironment.Stopping += (sender, args) =>
{
messagesListener.Stop(true);
Logger.LogInfo("Website is stopping. InstanceNo = " + instanceNo);
};
}
But for some reason this event Stopping is not called. Please help me. I hear that probably I need to use OnStop event from RoleEntryPoint class which I can inherit in my class, but I am not sure how to do it. I read this article: What's the difference between the webrole onStart() event and Application_Start() global.asax event?