/// <summary> /// Adds a middleware to the OWIN pipeline that sets the Strict-Transport-Security header. /// </summary> /// <param name="app">The <see cref="IAppBuilder" /> to which the middleware is added.</param> /// <param name="configurer">An <see cref="Action" /> that configures the options for the middleware.</param> /// <returns>The <see cref="IAppBuilder" /> supplied in the app parameter.</returns> public static IAppBuilder UseHsts(this IAppBuilder app, Action<IFluentHstsOptions> configurer) { if (app == null) throw new ArgumentNullException("app"); if (configurer == null) throw new ArgumentNullException("configurer"); var options = new HstsOptions(); configurer(options); new HstsConfigurationValidator().Validate(options); return app.Use(typeof(HstsMiddleware), options); }