Created
September 10, 2018 13:38
-
-
Save robertjf/5a55dff403a0f6756e565a34202d55ef to your computer and use it in GitHub Desktop.
If you're implementing a custom IHttpModule or including a third party Module like NWebSec, here's one way to connect up to any events exposed by your module
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 MyGlobalEventHandler : ApplicationEventHandler | |
{ | |
protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext) | |
{ | |
var nWebSecHttpHeaderSecurityModule = umbracoApplication.Modules["NWebSecHttpHeaderSecurityModule"] as HttpHeaderSecurityModule; | |
if (nWebSecHttpHeaderSecurityModule != null) | |
{ | |
nWebSecHttpHeaderSecurityModule.CspViolationReported += NWebSecHttpHeaderSecurityModule_CspViolationReported; | |
} | |
base.ApplicationStarted(umbracoApplication, applicationContext); | |
} | |
protected void NWebSecHttpHeaderSecurityModule_CspViolationReported(object sender, CspViolationReportEventArgs e) | |
{ | |
// Do something here | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment