I would like to have SaveChanges run at the end of all requests to my Web Service. can anybody help me?
I would like to have SaveChanges run at the end of all requests to my Web Service. can anybody help me?
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()
{
}
}