Skip to content

Instantly share code, notes, and snippets.

@sniffdk
Created June 6, 2018 09:40
Show Gist options
  • Save sniffdk/106361a2a7a38b255d4210c6e164b530 to your computer and use it in GitHub Desktop.
Save sniffdk/106361a2a7a38b255d4210c6e164b530 to your computer and use it in GitHub Desktop.
Snippet to demo how an http module can be used to check pdf requests
public class PdfModule : IHttpModule
{
public void Init(HttpApplication context)
{
context.PostAuthorizeRequest += PostAuthorizeRequest;
}
void PostAuthorizeRequest(object sender, EventArgs e)
{
var context = HttpContext.Current;
var url = context.Request.Url.AbsolutePath;
if (!url.EndsWith(".pdf"))
{
return;
}
// do some logic here, then just return if no further action is needed
}
public void Dispose()
{
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment