Asp net core web app defaults to displaying the currency in dollars after deploy

ASP.NET is a popular language used for developing web applications. One issue that developers face is the currency display in ASP.NET Core web apps after deployment. By default, ASP.NET Core web apps display currency in dollars. However, there are ways to customize this behavior and display the currency in a different format.

To solve this issue, we can make use of the CultureInfo class provided by ASP.NET Core. The CultureInfo class represents about a specific culture, including the language, /region, and formatting conventions. By setting the appropriate culture, we can control the currency display format in our web app.

To begin, let's assume we have a web app developed using ASP.NET Core. After deployment, the currency is in dollars, but we want it to be displayed in a different currency, such as euros. We can achieve this by modifying the culture settings in our app.

, we need to add the necessary code to our ASP.NET Core web app. Here's an of how we can modify the culture settings in the Startup.cs file:

using Microsoft..Builder;
using Microsoft.AspNetCore.Hosting;
using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.Extensions.Hosting;
using System.Globalization;

namespace YourAppName
     class Startup
        public Startup(IConfiguration configuration)
            Configuration = configuration;

        public IConfiguration Configuration { get; }

        public void ConfigureServices(IServiceCollection services)

        public void Configure(IApplicationBuilder app, IWebHostEnvironment env)
            // Set the culture to display currency in euros
            var cultureInfo = new CultureInfo("en-GB");
            cultureInfo.NumberFormat.CurrencySymbol = "€";
            CultureInfo.DefaultThreadCurrentCulture = cultureInfo;
            CultureInfo.DefaultThreadCurrentUICulture = cultureInfo;

            if (env.IsDevelopment())




            app.UseEndpoints(endpoints =>
                    name: "default",
                    pattern: "{controller=Home}/{action=Index}/{id?}");

In the above code, we set the culture to “en-GB” (English – United Kingdom) and modify the currency symbol to “€” (euro). By setting the DefaultThreadCurrentCulture and DefaultThreadCurrentUICulture properties of the CultureInfo class, we ensure that the currency is displayed in euros throughout our web app.

It's important to note that the culture settings will affect the entire web app, so make sure to choose the appropriate culture for your target audience.

Now, let's consider an example to demonstrate the effect of these culture settings. Suppose we have a Razor view that displays a currency value using the @ symbol. By default, the currency will be displayed in dollars. However, after modifying the culture settings, the currency will be displayed in euros.

    decimal currencyValue = 100.50m;

Display Currency Value

The currency value is: @currencyValue

In the above example, the currency value is set to 100.50. After modifying the culture settings, the currency value will be displayed as €100.50 instead of $100.50.

By customizing the culture settings in ASP.NET Core web apps, we can control the currency display format and ensure it meets the requirements of our target audience. Whether it's displaying the currency in euros, pounds, or any other format, ASP.NET Core provides the flexibility to achieve this customization.

In conclusion, to solve the issue of ASP.NET Core web apps defaulting to displaying currency in dollars after deployment, we can modify the culture settings in our app. By setting the appropriate culture and currency symbol, we can control the currency display format throughout the web app. This customization ensures that the currency is displayed in the desired format, such as euros, pounds, or any other currency symbol.

Rate this post

Leave a Reply

Your email address will not be published. Required fields are marked *

Table of Contents