Dirk Brockhaus
Dirk Brockhaus

Reputation: 5062

Getting the browser culture in a WCF service using ASP.NET and globalization

I have a website calling a WCF service and I want the service to run with the browser culture. I am using the service in ASP.NET compatibility mode. This is working so far - It is possible to set the culture of the WCF service using the culture and uiCulture of the globalization section.

My problem is that enableClientBasedCulture shows no effect. These are my globalization settings for the service:

<globalization enableClientBasedCulture="true" culture="auto" uiCulture="auto"/>

The service ignores these settings and uses the default culture.

Something I am missing? Is enableClientBasedCulture the wrong way to transfer the culture in this scenario?

Upvotes: 2

Views: 3407

Answers (1)

to StackOverflow
to StackOverflow

Reputation: 124696

For WCF services, I use an implementation of WS-I18N similar to this one.

If I've understood your configuration correctly, you have:

  • A browser on the client
  • ... accessing an ASP.NET application on your server
  • ... which calls a WCF service on the same or a different server (maybe in the same server application)

This will work as follows:

  • Browser requests an ASP.NET page.

  • ASP.NET appplication sets its culture to the client culture (enableClientBasedCulture =true)

  • ASP.NET application adds a WS-I18N SOAP header with the current culture when calling the WCF web service.

  • WCF service interprets the WS-I18N SOAP header, and sets its culture while processing the request.

Upvotes: 4

Related Questions