public override async Task <IDisplayResult> UpdateAsync(ReverseProxySettings section, BuildEditorContext context)
        {
            if (context.GroupId == SettingsGroupId)
            {
                var model = new ReverseProxySettingsViewModel();

                await context.Updater.TryUpdateModelAsync(model, Prefix);

                section.ForwardedHeaders = ForwardedHeaders.None;

                if (model.EnableXForwardedFor)
                {
                    section.ForwardedHeaders |= ForwardedHeaders.XForwardedFor;
                }

                if (model.EnableXForwardedHost)
                {
                    section.ForwardedHeaders |= ForwardedHeaders.XForwardedHost;
                }

                if (model.EnableXForwardedProto)
                {
                    section.ForwardedHeaders |= ForwardedHeaders.XForwardedProto;
                }

                // If the settings are valid, release the current tenant.
                if (context.Updater.ModelState.IsValid)
                {
                    await _shellHost.ReleaseShellContextAsync(_shellSettings);
                }
            }

            return(await EditAsync(section, context));
        }
        public override async Task <IDisplayResult> UpdateAsync(ReverseProxySettings section, BuildEditorContext context)
        {
            var user = _httpContextAccessor.HttpContext?.User;

            if (!await _authorizationService.AuthorizeAsync(user, Permissions.ManageReverseProxySettings))
            {
                return(null);
            }

            if (context.GroupId == SettingsGroupId)
            {
                var model = new ReverseProxySettingsViewModel();

                await context.Updater.TryUpdateModelAsync(model, Prefix);

                section.ForwardedHeaders = ForwardedHeaders.None;

                if (model.EnableXForwardedFor)
                {
                    section.ForwardedHeaders |= ForwardedHeaders.XForwardedFor;
                }

                if (model.EnableXForwardedHost)
                {
                    section.ForwardedHeaders |= ForwardedHeaders.XForwardedHost;
                }

                if (model.EnableXForwardedProto)
                {
                    section.ForwardedHeaders |= ForwardedHeaders.XForwardedProto;
                }

                // If the settings are valid, release the current tenant.
                if (context.Updater.ModelState.IsValid)
                {
                    await _shellHost.ReleaseShellContextAsync(_shellSettings);
                }
            }

            return(await EditAsync(section, context));
        }
        public override async Task <IDisplayResult> UpdateAsync(ReverseProxySettings settings, BuildEditorContext context)
        {
            if (context.GroupId == SettingsGroupId)
            {
                var model = new ReverseProxySettingsViewModel();

                await context.Updater.TryUpdateModelAsync(model, Prefix);

                settings.ForwardedHeaders = ForwardedHeaders.None;

                if (model.EnableXForwardedFor)
                {
                    settings.ForwardedHeaders |= ForwardedHeaders.XForwardedFor;
                }

                if (model.EnableXForwardedHost)
                {
                    settings.ForwardedHeaders |= ForwardedHeaders.XForwardedHost;
                }

                if (model.EnableXForwardedProto)
                {
                    settings.ForwardedHeaders |= ForwardedHeaders.XForwardedProto;
                }
            }

            if (_memoryCache.Get(RestartPendingCacheKey) == null)
            {
                var entry = _memoryCache.CreateEntry(RestartPendingCacheKey);
                _memoryCache.Set(entry.Key, entry, new MemoryCacheEntryOptions {
                    Priority = CacheItemPriority.NeverRemove
                });
            }

            return(await EditAsync(settings, context));
        }