Created
June 6, 2018 09:40
-
-
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
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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