Execute a method when Webservice starts

3

I have a Webservice that is working normally. At this point there was a need to execute a method called "RecoverFile" that needs to be executed as soon as Webservice starts. This is a method to upload some data from the database when Webservice comes back from some failure, such as power outage, accidental reboot, etc. How can I do this without having to consume this method in another application?

    
asked by anonymous 09.11.2015 / 18:36

1 answer

4

Make your static method into a separate class. For example:

public static class Inicializacao 
{
    public void RecuperarAposFalha() 
    {
        /* Coloque aqui os passos para recuperação. */
    }
}

Call the method in Application_Start of file Global.asax :

    protected void Application_Start()
    {
        Inicializacao.RecuperarAposFalha();
        ...
    }
    
09.11.2015 / 18:44