简体   繁体   English

AbpUserRequestCultureProvider 返回了以下不受支持的文化

[英]AbpUserRequestCultureProvider returned the following unsupported cultures

When I check my logs on my Angular ASP.NET application, I'm repeatedly getting this error message:当我检查我的 Angular ASP.NET 应用程序的日志时,我反复收到此错误消息:

WARN 2018-07-19 05:43:09,596 [42 ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported cultures 'null'. WARN 2018-07-19 05:43:09,596 [42 ] calization.RequestLocalizationMiddleware - AbpUserRequestCultureProvider returned the following unsupported UI Cultures 'null'. WARN 2018-07-19 05:43:09,596 [42 ] calization.RequestLocalizationMiddleware - AbpLocalizationHeaderRequestCultureProvider returned the following unsupported cultures 'null'

Has anyone had any experience with this, or what could be causing the issue?有没有人有这方面的经验,或者可能导致问题的原因是什么?

Any help would be appreciated.任何帮助,将不胜感激。

It means ABP couldn't get user's language from header of the request.这意味着 ABP 无法从请求的标头中获取用户的语言。 Normally it checks the header .AspNetCore.Culture and returns null if not found.通常它会检查标头.AspNetCore.Culture并在未找到时返回 null。 Check your request headers...检查您的请求标头...

A sample header value is below;示例标题值如下;

.AspNetCore.Culture=c=en|uic=en
  • c:Culture c:文化
  • uic: Ui Culture uic:UI文化

我的标题失败了: .AspNetCore.Culture ,这个适用于我的项目:标题: Accept-Language值:“en-US”。

'null' culture issue was fixed in Prevent null being saved into user's DefaultLanguage (ABP 4.9, Sep 2019). 'null'文化问题已在防止将 null 保存到用户的 DefaultLanguage (ABP 4.9,2019 年 9 月)中得到修复。


Another issue is that Nginx as a reverse proxy will not pass headers that contain a period.另一个问题是Nginx 作为反向代理不会传递包含句点的标头。

In this case, the ".AspNetCore.Culture" header.在这种情况下, ".AspNetCore.Culture"标头。

Related: Cannot get header that contains a period from NGINX for the "Abp.TenantId" header (ABP 4.4, Mar 2019).相关:无法从 NGINX 获取包含句点的标头,用于"Abp.TenantId"标头(ABP "Abp.TenantId"年 3 月)。

ABP 6.0+ ABP 6.0+

AbpLocalizationHeaderRequestCultureProvider.HeaderName is configurable. AbpLocalizationHeaderRequestCultureProvider.HeaderName是可配置的。

  1. In Startup.cs#L132 , get AbpLocalizationHeaderRequestCultureProvider and set its HeaderName :Startup.cs#L132 ,GET AbpLocalizationHeaderRequestCultureProvider并设置其HeaderName
// app.UseAbpRequestLocalization();
   app.UseAbpRequestLocalization(options =>
   {
       var headerProvider = options.RequestCultureProviders.OfType<AbpLocalizationHeaderRequestCultureProvider>().First();
       headerProvider.HeaderName = "AspNetCore-Culture";
   });
  1. In app-initializer.ts#L122 , replace '.AspNetCore.Culture' with 'AspNetCore-Culture' :app-initializer.ts#L122 中,将'.AspNetCore.Culture'替换为'AspNetCore-Culture'
// '.AspNetCore.Culture': `c=${cookieLangValue}|uic=${cookieLangValue}`,
    'AspNetCore-Culture': `c=${cookieLangValue}|uic=${cookieLangValue}`,

Below ABP 6.0低于 ABP 6.0

  1. Copy AbpLocalizationHeaderRequestCultureProvider with the patch to your project as MyLocalizationHeaderRequestCultureProvider .复制AbpLocalizationHeaderRequestCultureProvider的补丁,以项目为MyLocalizationHeaderRequestCultureProvider
  2. In Startup.cs#L132 , insert an instance of MyLocalizationHeaderRequestCultureProvider into RequestCultureProviders after setting its HeaderName .Startup.cs#L132 ,插入的一个实例MyLocalizationHeaderRequestCultureProviderRequestCultureProviders设置它的后HeaderName
// app.UseAbpRequestLocalization();
   app.UseAbpRequestLocalization(options =>
   {
       var headerProvider = new MyLocalizationHeaderRequestCultureProvider();
       headerProvider.HeaderName = "AspNetCore-Culture";
       options.RequestCultureProviders.Insert(2, headerProvider);
   });
  1. In app-initializer.ts#L122 , replace '.AspNetCore.Culture' with 'AspNetCore-Culture' .app-initializer.ts#L122 中,将'.AspNetCore.Culture'替换为'AspNetCore-Culture'

Alternative选择

You can turn off ignore "invalid" headers in Nginx.您可以在 Nginx 中关闭忽略“无效”标头

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 ASP.NET Core MVC本地化警告:AcceptLanguageHeaderRequestCultureProvider返回了以下不支持的区域性 - ASP.NET Core MVC Localization Warning: AcceptLanguageHeaderRequestCultureProvider returned the following unsupported cultures 远程服务器返回错误:(415)不支持的媒体类型 - The remote server returned an error: (415) Unsupported Media Type 具有不同文化的日期时间转换 - DateTime Conversion with Different Cultures 在标记为 Controller 的 APIController 上使用 Paging 时返回不支持的媒体类型 - Unsupported Media Type returned when using Paging on APIController marked Controller 令牌响应已成功返回:unsupported_grant_type - The token response was successfully returned: unsupported_grant_type Http 响应返回的 Stream 响应不可作为响应。长度抛出“不支持” - Stream returned by Http response is not seekable as response.Length throws “unsupported” 在不同文化中格式化数字 - Formatting numbers in different cultures 如何使用习惯文化? - How to use custom cultures? 指定应用程序支持的文化 - Specify cultures supported by application 嵌套的lambda表达式和字符串文化 - Nested lambda expressions and string cultures
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM