Full-Stack freelance Umbraco developer in the UK.

George Phillipson - Freelance Umbraco developer

Security Header Expect CT

Security header Expect CT
public class ExpectCtHeader : IHttpModule
    {

        public void Init(HttpApplication app)
        {
            app.BeginRequest += (App_BeginRequest);

        }

        private void App_BeginRequest(object sender, EventArgs e)
        {
            if (HttpContext.Current.Request.IsSecureConnection)
            {
                string baseUrl = "https://xxxxxxxx.report-uri.com/r/d/ct/reportOnly";
                string headerValue = $"max-age=0, report-uri=\"{baseUrl}";
                HttpContext.Current.Response.AddHeader("Expect-CT",headerValue);
            }
        }

        public void Dispose()
        {
            // Needed for IHttpModule
        }
    }
<add name="ExpectCtHeader" type="Web.RequiresHttps.ExpectCtHeader, Web.RequiresHttps" />
Expect CT-Header

Please enter your comment.