Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/asp.net-core/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Asp.net core ASP.Net核心,基于子域设置当前区域性?_Asp.net Core_Asp.net Core Mvc - Fatal编程技术网

Asp.net core ASP.Net核心,基于子域设置当前区域性?

Asp.net core ASP.Net核心,基于子域设置当前区域性?,asp.net-core,asp.net-core-mvc,Asp.net Core,Asp.net Core Mvc,我试图弄清楚如何在ASP.NETCore1.1中基于子域设置站点区域性 我的Startup.cs中有以下内容 services.Configure(选项=> { var supportedCultures=新列表 { 新文化信息(“美国”), 新文化信息(“fil PH”) }; options.DefaultRequestCulture=newrequestculture(culture:“en-US”,uiCulture:“en-US”); options.SupportedCultures

我试图弄清楚如何在ASP.NETCore1.1中基于子域设置站点区域性

我的Startup.cs中有以下内容

services.Configure(选项=>
{
var supportedCultures=新列表
{
新文化信息(“美国”),
新文化信息(“fil PH”)
};
options.DefaultRequestCulture=newrequestculture(culture:“en-US”,uiCulture:“en-US”);
options.SupportedCultures=SupportedCultures;
options.supportedCultures=supportedCultures;
if(UrlManagement.IsLocalizedUrl())
{
options.RequestCultureProviders.Insert(0,新的CustomRequestCultureProvider(异步上下文=>
{
CultureInfo CultureInfo=UrlManagement.GetCultureInfo-FromURL();
ProviderCultureResult ProviderCultureResult=等待新的ProviderCultureResult(cultureInfo.Name);
返回providerCultureResult;
}));
}
});
它在构建时抱怨这个错误

“ProviderCultureResult”不包含“GetAwaiter”的定义 并且没有扩展方法“GetAwaiter”接受 找不到类型“ProviderCultureResult”(是否缺少使用 指令或组件引用?)

如果我删除了wait,那么它会抱怨我应该有一个wait

如果我删除了异步,那么它会抱怨它应该是异步的

如果我删除了wait,那么它会抱怨我应该有一个wait


否。警告您的
异步
函数没有任何
等待
,将同步运行。这不是一个错误。您可以忽略此项。

谢谢。建议插入RequestCultureProvider的方法会抛出警告,这有点恼人。
services.Configure<RequestLocalizationOptions>(options =>
{
    var supportedCultures = new List<CultureInfo>
    {
        new CultureInfo("en-US"),
        new CultureInfo("fil-PH")
    };

    options.DefaultRequestCulture = new RequestCulture(culture: "en-US", uiCulture: "en-US");
    options.SupportedCultures = supportedCultures;
    options.SupportedUICultures = supportedCultures;
    if (UrlManagement.IsLocalizedUrl())
    {
        options.RequestCultureProviders.Insert(0, new CustomRequestCultureProvider(async context =>
        {
                CultureInfo cultureInfo = UrlManagement.GetCultureInfoFromUrl();
            ProviderCultureResult providerCultureResult = await new ProviderCultureResult(cultureInfo.Name);
            return providerCultureResult;
        }));
    }
});