Does ASMX Web Service contain an event to end the request?

Asked

Viewed 82 times

1

I would like to make sure that at the end of all requests to my Web Service the Savechanges runs. Someone could help me?

1 answer

2


You can implement an Ihttpmodule, or use Httpapplication events to do so.

Ihttpmodule

public class MeuModuloHttp : IHttpModule
{
    public String ModuleName
    {
        get { return "MeuModuloHttp"; }
    }

    public void Init(HttpApplication application)
    {
        application.EndRequest += (new EventHandler(this.Application_EndRequest));
    }

    private void Application_EndRequest(Object source, EventArgs e)
    {
        var application = (HttpApplication)source;
        var context = application.Context;
        if (context.Request.Url.AbsolutePath.EndsWith(".asmx"))
        {
            // executar algo
        }
    }

    public void Dispose()
    {
    }
}

Browser other questions tagged

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