@using Microsoft.AspNetCore.Http @using Microsoft.Extensions.Options @code { [CascadingParameter] private HttpContext HttpContext { get; set; } = default!; [Inject] private ThemeService ThemeService { get; set; } = default!; [Inject] private IOptions Options { get; set; } = default!; protected override void OnInitialized() { base.OnInitialized(); if (HttpContext != null) { var theme = HttpContext.Request.Cookies["CartriXTheme"]; if (!string.IsNullOrEmpty(theme)) { ThemeService.SetTheme(theme, false); } else { HttpContext.Response.Cookies.Append("CartriXTheme", "material", new CookieOptions { Secure = Options.Value.IsSecure, Expires = DateTimeOffset.Now.Add(Options.Value.Duration) }); } } } }