Skip to content

Instantly share code, notes, and snippets.

@robertjf
Created September 10, 2018 13:38
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save robertjf/5a55dff403a0f6756e565a34202d55ef to your computer and use it in GitHub Desktop.
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
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