Is there a way to intercept the caller's language in the ASP.NET Core Web API in C#?
I'm referring to the natural language of the caller.
I solved the issue with the following code :
private string GetCulture()
{
var headers = this.Request.Headers;
if (headers.ContainsKey("Accept-Language"))
{
Microsoft.Extensions.Primitives.StringValues token;
headers.TryGetValue("Accept-Language",out token);
return token[0].ToString().Split(';')[0].Split(',')[0];
}
return ("en-GB");
}
Thanks to all.