Skip to content

Defaults

The Defaults() method provided by the practices module adds some useful concerns to your web server to enable features such as compression or client side caching. This way, you will have a well configured server instance without the need of adding everything by yourself.

await Host.Create()
          .Handler(...)
          .Defaults()
          .RunAsync();

If you would like to opt out of a default feature, or enable one that is off by default, you may pass a flag as needed:

await Host.Create()
          .Handler(...)
          .Defaults(compression: false, rangeSupport: true)
          .RunAsync();

Defaults() accepts the following flags:

FlagDefaultEnables
compressiontrueCompression of response content.
decompressionfalseDecompression of request content.
secureUpgradetrueAutomatic upgrade of insecure requests.
strictTransporttrueHSTS via a Strict-Transport-Security header.
clientCachingtrueClient side caching via ETag validation.
rangeSupportfalsePartial responses for range requests.
preventSniffingfalseMIME type sniffing prevention via X-Content-Type-Options.