public void Configure(RewriteOptions options) { // Defaults var enforeSsl = false; var usePermanentRedirect = false; var sslPort = 443; // Get settings var settings = _httpsSettingsStore.GetAsync().GetAwaiter().GetResult(); if (settings != null) { enforeSsl = settings.EnforceSsl; usePermanentRedirect = settings.UsePermanentRedirect; sslPort = settings.SslPort; } if (enforeSsl) { options.AddRedirectToHttps( usePermanentRedirect ? StatusCodes.Status301MovedPermanently : StatusCodes.Status302Found, sslPort); } }
private async Task <HttpsSettingsViewModel> GetModel() { var settings = await _httpsSettingsStore.GetAsync(); if (settings != null) { return(new HttpsSettingsViewModel() { EnforceSsl = settings.EnforceSsl, UsePermanentRedirect = settings.UsePermanentRedirect, SslPort = settings.SslPort }); } return(new HttpsSettingsViewModel() { EnforceSsl = false, UsePermanentRedirect = false, SslPort = 443 }); }