How to properly detect user browser culture in asp.net mvc
<p>I see that there are similar questions to this one but I haven't found an answer to my question there and therefore, I decided to ask a question to my own. </p>

<p>The situation: I want to get the user's browser language so that I can set his session culture key or store the localization in the database if the user has an account in order to show this user my website on his language until he changes his lang preference manually.</p>

<p>My issue is: Everything seems to work pretty fine in theory but...</p>

<p>These are my browser language preferences
I know that they are set on particular order</p>

<p><a href="https://i.stack.imgur.com/k5PEV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k5PEV.png" alt="1"></a></p>

<p>That order is sent to the server exactly as it is no matter that my browser display language is set to Bulgarian my preference still remain en-US</p>

<p><a href="https://i.stack.imgur.com/5bVIu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5bVIu.png" alt="2"></a></p>

<p>This is a sample code snippet to show what my dev tools console says about my browser display language</p>

<p><a href="https://i.stack.imgur.com/NKMU3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NKMU3.png" alt="3"></a></p>

<p>And in my code I cannot know what is the browser language I can only get the preferred language to the user then I get the Languages[0]</p>

<p><a href="https://i.stack.imgur.com/B2dZ3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B2dZ3.png" alt="4"></a></p>

<p>Is there a way to get this display language. I cannot use JS to send it because I have a problem that my first request is always displaying the page in English than when the session is set it displays it localized. Probably there is a workaround to check and set a particular header from JS but I am thinking of a more gallant way to do it only with C#. </p>

<p>I am not sure it is the proper way. I have overridden on OnActionExecuting in my BaseController and I am setting the current thread's localizations based on the user's locale and he may change by drop down his preferred language also that overrides and reset the session language key. I know also that there is an auto locale option but I am not sure if it is good enough and also I don't know how it works and how can a user simply change his language while the auto globalization is turned on. </p>

<p>For now, I just want to get the proper browser display's language and I need some help from someone that has dealt with localizations.</p>