Search code examples
asp.net-mvc-3globalization

MVC 3 Globalization - Australian Currency


I have problem with austalian culture. I set this by the code:

        string id = "en-AU";
        string ret = Request.ServerVariables["HTTP_REFERER"] ?? "/";
        string culture = CultureHelper.GetValidCulture(id);
        HttpCookie cookie = Request.Cookies["_culture"];
        if (cookie != null)
            cookie.Value = culture;
        else {
            cookie = new HttpCookie("_culture");
            cookie.HttpOnly = false;
            cookie.Value = culture;
            cookie.Expires = DateTime.Now.AddYears(1);
        }
        Response.Cookies.Add(cookie);

then I want to display a price in AUD:

 @String.Format("{0:C}", item.Price

but I get e.g $55.00. Why ?


Solution

  • In your code you are not actually applying the culture anywhere. Something like:

    CultureInfo userCulture = CultureInfo.GetCultureInfo(culture);    
    Thread.CurrentThread.CurrentCulture = userCulture;
    Thread.CurrentThread.CurrentUICulture = userCulture;