remove Microsoft.AspNetCore.Http
This commit is contained in:
parent
588748230e
commit
f09709aedb
|
@ -51,6 +51,7 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
services.AddScoped<IUrlMappingService, UrlMappingService>();
|
services.AddScoped<IUrlMappingService, UrlMappingService>();
|
||||||
services.AddScoped<IVisitorService, VisitorService>();
|
services.AddScoped<IVisitorService, VisitorService>();
|
||||||
services.AddScoped<ISyncService, SyncService>();
|
services.AddScoped<ISyncService, SyncService>();
|
||||||
|
services.AddScoped<ILocalizationCookieService, LocalizationCookieService>();
|
||||||
|
|
||||||
// providers
|
// providers
|
||||||
services.AddScoped<ITextEditor, Oqtane.Modules.Controls.QuillJSTextEditor>();
|
services.AddScoped<ITextEditor, Oqtane.Modules.Controls.QuillJSTextEditor>();
|
||||||
|
|
|
@ -26,7 +26,6 @@
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="9.0.0-rc.2.24474.3" />
|
<PackageReference Include="Microsoft.AspNetCore.Components.WebAssembly.Authentication" Version="9.0.0-rc.2.24474.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.0-rc.2.24474.3" />
|
<PackageReference Include="Microsoft.Extensions.Localization" Version="9.0.0-rc.2.24474.3" />
|
||||||
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0-rc.2.24473.5" />
|
<PackageReference Include="Microsoft.Extensions.Http" Version="9.0.0-rc.2.24473.5" />
|
||||||
<PackageReference Include="Microsoft.AspNetCore.Http" Version="2.2.2" />
|
|
||||||
</ItemGroup>
|
</ItemGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|
|
@ -0,0 +1,17 @@
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Service to set localization cookie
|
||||||
|
/// </summary>
|
||||||
|
public interface ILocalizationCookieService
|
||||||
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Set the localization cookie
|
||||||
|
/// </summary>
|
||||||
|
/// <param name="culture"></param>
|
||||||
|
/// <returns></returns>
|
||||||
|
Task SetLocalizationCookieAsync(string culture);
|
||||||
|
}
|
||||||
|
}
|
18
Oqtane.Client/Services/LocalizationCookieService.cs
Normal file
18
Oqtane.Client/Services/LocalizationCookieService.cs
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
using System.Net.Http;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Oqtane.Documentation;
|
||||||
|
using Oqtane.Shared;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
[PrivateApi("Don't show in the documentation, as everything should use the Interface")]
|
||||||
|
public class LocalizationCookieService : ServiceBase, ILocalizationCookieService
|
||||||
|
{
|
||||||
|
public LocalizationCookieService(HttpClient http, SiteState siteState) : base(http, siteState) { }
|
||||||
|
|
||||||
|
public Task SetLocalizationCookieAsync(string culture)
|
||||||
|
{
|
||||||
|
return Task.CompletedTask; // only used in server side rendering
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,9 +1,9 @@
|
||||||
@using System.Globalization
|
@using System.Globalization
|
||||||
@using Oqtane.Models
|
@using Oqtane.Models
|
||||||
@using Microsoft.AspNetCore.Http
|
|
||||||
@namespace Oqtane.Themes.Controls
|
@namespace Oqtane.Themes.Controls
|
||||||
@inherits ThemeControlBase
|
@inherits ThemeControlBase
|
||||||
@inject ILanguageService LanguageService
|
@inject ILanguageService LanguageService
|
||||||
|
@inject ILocalizationCookieService LocalizationCookieService
|
||||||
@inject NavigationManager NavigationManager
|
@inject NavigationManager NavigationManager
|
||||||
|
|
||||||
@if (_supportedCultures?.Count() > 1)
|
@if (_supportedCultures?.Count() > 1)
|
||||||
|
@ -37,10 +37,7 @@
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string ButtonClass { get; set; } = "btn-outline-secondary";
|
public string ButtonClass { get; set; } = "btn-outline-secondary";
|
||||||
|
|
||||||
[CascadingParameter]
|
protected override async Task OnParametersSetAsync()
|
||||||
HttpContext HttpContext { get; set; }
|
|
||||||
|
|
||||||
protected override void OnParametersSet()
|
|
||||||
{
|
{
|
||||||
MenuAlignment = DropdownAlignment.ToLower() == "right" ? "dropdown-menu-end" : string.Empty;
|
MenuAlignment = DropdownAlignment.ToLower() == "right" ? "dropdown-menu-end" : string.Empty;
|
||||||
|
|
||||||
|
@ -51,17 +48,7 @@
|
||||||
var culture = PageState.QueryString["culture"];
|
var culture = PageState.QueryString["culture"];
|
||||||
if (_supportedCultures.Any(item => item.Name == culture))
|
if (_supportedCultures.Any(item => item.Name == culture))
|
||||||
{
|
{
|
||||||
var localizationCookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture));
|
await LocalizationCookieService.SetLocalizationCookieAsync(culture);
|
||||||
|
|
||||||
HttpContext.Response.Cookies.Append(CookieRequestCultureProvider.DefaultCookieName, localizationCookieValue, new CookieOptions
|
|
||||||
{
|
|
||||||
Path = "/",
|
|
||||||
Expires = DateTimeOffset.UtcNow.AddYears(365),
|
|
||||||
SameSite = Microsoft.AspNetCore.Http.SameSiteMode.Lax, // Set SameSite attribute
|
|
||||||
Secure = true, // Ensure the cookie is only sent over HTTPS
|
|
||||||
HttpOnly = false // cookie is updated using JS Interop in Interactive render mode
|
|
||||||
});
|
|
||||||
|
|
||||||
}
|
}
|
||||||
NavigationManager.NavigateTo(NavigationManager.Uri.Replace($"?culture={culture}", ""));
|
NavigationManager.NavigateTo(NavigationManager.Uri.Replace($"?culture={culture}", ""));
|
||||||
}
|
}
|
||||||
|
|
|
@ -1,7 +1,5 @@
|
||||||
@namespace Oqtane.UI
|
@namespace Oqtane.UI
|
||||||
@using Microsoft.AspNetCore.Http
|
|
||||||
@inject IInstallationService InstallationService
|
@inject IInstallationService InstallationService
|
||||||
@inject IJSRuntime JSRuntime
|
|
||||||
@inject SiteState SiteState
|
@inject SiteState SiteState
|
||||||
|
|
||||||
@if (_initialized)
|
@if (_initialized)
|
||||||
|
@ -48,9 +46,6 @@
|
||||||
[Parameter]
|
[Parameter]
|
||||||
public string Platform { get; set; } = "";
|
public string Platform { get; set; } = "";
|
||||||
|
|
||||||
[CascadingParameter]
|
|
||||||
HttpContext HttpContext { get; set; }
|
|
||||||
|
|
||||||
private bool _initialized = false;
|
private bool _initialized = false;
|
||||||
private bool _installed = false;
|
private bool _installed = false;
|
||||||
private string _display = "display: none;";
|
private string _display = "display: none;";
|
||||||
|
@ -62,7 +57,7 @@
|
||||||
SiteState.AntiForgeryToken = AntiForgeryToken;
|
SiteState.AntiForgeryToken = AntiForgeryToken;
|
||||||
SiteState.AuthorizationToken = AuthorizationToken;
|
SiteState.AuthorizationToken = AuthorizationToken;
|
||||||
SiteState.Platform = Platform;
|
SiteState.Platform = Platform;
|
||||||
SiteState.IsPrerendering = (HttpContext != null) ? true : false;
|
SiteState.IsPrerendering = !RendererInfo.IsInteractive;
|
||||||
|
|
||||||
if (Runtime == Runtimes.Hybrid)
|
if (Runtime == Runtimes.Hybrid)
|
||||||
{
|
{
|
||||||
|
|
|
@ -113,8 +113,11 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
|
|
||||||
internal static IServiceCollection AddOqtaneTransientServices(this IServiceCollection services)
|
internal static IServiceCollection AddOqtaneTransientServices(this IServiceCollection services)
|
||||||
{
|
{
|
||||||
// repositories
|
// services
|
||||||
services.AddTransient<ISiteService, ServerSiteService>();
|
services.AddTransient<ISiteService, ServerSiteService>();
|
||||||
|
services.AddTransient<ILocalizationCookieService, ServerLocalizationCookieService>();
|
||||||
|
|
||||||
|
// repositories
|
||||||
services.AddTransient<IModuleDefinitionRepository, ModuleDefinitionRepository>();
|
services.AddTransient<IModuleDefinitionRepository, ModuleDefinitionRepository>();
|
||||||
services.AddTransient<IThemeRepository, ThemeRepository>();
|
services.AddTransient<IThemeRepository, ThemeRepository>();
|
||||||
services.AddTransient<IAliasRepository, AliasRepository>();
|
services.AddTransient<IAliasRepository, AliasRepository>();
|
||||||
|
@ -130,7 +133,6 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
services.AddTransient<IPermissionRepository, PermissionRepository>();
|
services.AddTransient<IPermissionRepository, PermissionRepository>();
|
||||||
services.AddTransient<ISettingRepository, SettingRepository>();
|
services.AddTransient<ISettingRepository, SettingRepository>();
|
||||||
services.AddTransient<ILogRepository, LogRepository>();
|
services.AddTransient<ILogRepository, LogRepository>();
|
||||||
services.AddTransient<ILocalizationManager, LocalizationManager>();
|
|
||||||
services.AddTransient<IJobRepository, JobRepository>();
|
services.AddTransient<IJobRepository, JobRepository>();
|
||||||
services.AddTransient<IJobLogRepository, JobLogRepository>();
|
services.AddTransient<IJobLogRepository, JobLogRepository>();
|
||||||
services.AddTransient<INotificationRepository, NotificationRepository>();
|
services.AddTransient<INotificationRepository, NotificationRepository>();
|
||||||
|
@ -153,12 +155,12 @@ namespace Microsoft.Extensions.DependencyInjection
|
||||||
services.AddTransient<ILogManager, LogManager>();
|
services.AddTransient<ILogManager, LogManager>();
|
||||||
services.AddTransient<IUpgradeManager, UpgradeManager>();
|
services.AddTransient<IUpgradeManager, UpgradeManager>();
|
||||||
services.AddTransient<IUserManager, UserManager>();
|
services.AddTransient<IUserManager, UserManager>();
|
||||||
|
services.AddTransient<ILocalizationManager, LocalizationManager>();
|
||||||
// obsolete - replaced by ITenantManager
|
|
||||||
services.AddTransient<ITenantResolver, TenantResolver>();
|
|
||||||
|
|
||||||
services.AddTransient<ITokenReplace, TokenReplace>();
|
services.AddTransient<ITokenReplace, TokenReplace>();
|
||||||
|
|
||||||
|
// obsolete
|
||||||
|
services.AddTransient<ITenantResolver, TenantResolver>(); // replaced by ITenantManager
|
||||||
|
|
||||||
return services;
|
return services;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
35
Oqtane.Server/Services/LocalizationCookieService.cs
Normal file
35
Oqtane.Server/Services/LocalizationCookieService.cs
Normal file
|
@ -0,0 +1,35 @@
|
||||||
|
using System;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using Microsoft.AspNetCore.Http;
|
||||||
|
using Microsoft.AspNetCore.Localization;
|
||||||
|
using Oqtane.Documentation;
|
||||||
|
|
||||||
|
namespace Oqtane.Services
|
||||||
|
{
|
||||||
|
[PrivateApi("Don't show in the documentation, as everything should use the Interface")]
|
||||||
|
public class ServerLocalizationCookieService : ILocalizationCookieService
|
||||||
|
{
|
||||||
|
private readonly IHttpContextAccessor _accessor;
|
||||||
|
|
||||||
|
public ServerLocalizationCookieService(IHttpContextAccessor accessor)
|
||||||
|
{
|
||||||
|
_accessor = accessor;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Task SetLocalizationCookieAsync(string culture)
|
||||||
|
{
|
||||||
|
var localizationCookieValue = CookieRequestCultureProvider.MakeCookieValue(new RequestCulture(culture));
|
||||||
|
|
||||||
|
_accessor.HttpContext.Response.Cookies.Append(CookieRequestCultureProvider.DefaultCookieName, localizationCookieValue, new CookieOptions
|
||||||
|
{
|
||||||
|
Path = "/",
|
||||||
|
Expires = DateTimeOffset.UtcNow.AddYears(365),
|
||||||
|
SameSite = SameSiteMode.Lax,
|
||||||
|
Secure = true, // Ensure the cookie is only sent over HTTPS
|
||||||
|
HttpOnly = false // cookie is updated using JS Interop in Interactive render mode
|
||||||
|
});
|
||||||
|
|
||||||
|
return Task.CompletedTask;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user