Does ASMX Web Service contain any events for the end of the request?

1

I would like to have SaveChanges run at the end of all requests to my Web Service. can anybody help me?

    
asked by anonymous 19.02.2014 / 14:19

1 answer

2

You can implement an IHttpModule, or use the HttpApplication events for this.

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()
    {
    }
}
    
19.02.2014 / 14:31