Reputation: 4855
I am trying to figure out how to set a sites Culture based on a subdomain in ASP.Net Core 1.1.
I have the following in my Startup.cs
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;
}));
}
});
It is complaining with this error at build time.
'ProviderCultureResult' does not contain a definition for 'GetAwaiter' and no extension method 'GetAwaiter' accepting a first argument of type 'ProviderCultureResult' could be found (are you missing a using directive or an assembly reference?)
If I remove the await, then it complains that I should have an await.
If I remove the async, then it complains that it should be async.
Upvotes: 0
Views: 286
Reputation: 16795
If I remove the await, then it complains that I should have an await.
No. It warns you that your async
function does not have any await
and will run synchronously. It's not an error. You can ignore this.
Upvotes: 1