ASP.NET development server ignores browser culture

I am trying to implement a simple example of how ASP.NET is changing culture. I am running Windows 7, IE 8 and VS 2008. My shortcut looks like this:

<asp:Label ID="TextBox1" runat="server" meta:resourcekey="Greeting"></asp:Label>

      

I have two files in App_LocalResources: Default.aspx.resx and Default.aspx.fr.resx.

In these I have a string value called "Greeting.Text" and the value is "Hello!" on one page and "Bonjour!" in a different.

I have my browser that prefers fr-FR as its default language. When I open a page with ASP.NET Development Server via F5 or Shift-F5, that page seems to recognize my culture as en-US, no matter what I set in the Browser's Languages ​​dialog.

That being said, the browser is configured correctly as Google appears in French.

When I add a shortcut to the page and set the label text to the name CurrentCulture or CurrentUICulture, I get en-US, which is clearly not what I entered.

Does anyone know why this is not working as expected?

+1


a source to share


1 answer


ASP.NET does not automatically change the culture based on the browser. Add this to your web.config:

<configuration>
    <system.web>
        <globalization culture="auto"
                       enableBestFitResponseEncoding="false"
                       fileEncoding="utf-8"
                       requestEncoding="utf-8"
                       responseEncoding="utf-8"
                       responseHeaderEncoding="utf-8"
                       uiCulture="auto"/>
    </system.web>
</configuration>

      



Note that culture="auto"

and uiCulture="auto"

are important bits for what you are looking for, although this is probably a good idea too. Also note that the enableClientBasedCulture attribute you see in the documentation is not currently used by ASP.NET.

+5


a source







All Articles