Run a method when Webservice is Started

Asked

Viewed 61 times

4

I have a Webservice that’s working normally. At this point arose the need to execute a method called "Recuperaraposfalha" that needs to be executed as soon as the Webservice is started. This is a method to upload some database data when the Webservice comes back from some fault like power outage, accidental reboot, etc. How can I do this without consuming this method in another application ?

1 answer

5


Make your static method in 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 the archive Global.asax:

    protected void Application_Start()
    {
        Inicializacao.RecuperarAposFalha();
        ...
    }

Browser other questions tagged

You are not signed in. Login or sign up in order to post.