.NET Core.NET Framework Acronym Glossary.NET Framework ADO.NET.NET Framework CLR.NET Framework Code Contracts.NET Framework Collections.NET Framework Custom Types.NET Framework DateTime parsing.NET Framework Dependency Injection.NET Framework Dictionaries.NET Framework Encryption / Cryptography.NET Framework Exceptions.NET Framework Expression Trees.NET Framework File Input/Output.NET Framework ForEach.NET Framework Garbage Collection.NET Framework Globalization in ASP.NET MVC using Smart internationalization for ASP.NET.NET Framework HTTP clients.NET Framework HTTP servers.NET Framework Introduction.NET Framework JIT compiler.NET Framework JSON Serialization.NET Framework LINQ.NET Framework Managed Extensibility.NET Framework Memory management.NET Framework Networking.NET Framework NuGet packaging system.NET Framework Platform Invoke.NET Framework Process and Thread affinity setting.NET Framework Reading and writing Zip files.NET Framework ReadOnlyCollections.NET Framework Reflection.NET Framework Regular Expressions (System.Text.RegularExpressions).NET Framework Serial Ports.NET Framework Settings.NET Framework SpeechRecognitionEngine class to recognize speech.NET Framework Stack and Heap.NET Framework Strings.NET Framework Synchronization Contexts.NET Framework System.Diagnostics.NET Framework System.IO.NET Framework System.IO.File class.NET Framework System.Net.Mail.NET Framework System.Reflection.Emit namespace.NET Framework System.Runtime.Caching.MemoryCache (ObjectCache).NET Framework Task Parallel Library (TPL).NET Framework Task Parallel Library (TPL) API Overviews.NET Framework Threading.NET Framework TPL Dataflow.NET Framework Unit testing.NET Framework Upload file and POST data to webserver.NET Framework Using ProgressT and IProgressT.NET Framework VB Forms.NET Framework Work with SHA1 in C Sharp.NET Framework Write to and read from StdErr stream.NET Framework XmlSerializerJSON in .NET with Newtonsoft.JsonParallel processing using .NET framework

.NET Framework Globalization in ASP.NET MVC using Smart internationalization for ASP.NET

From WikiOD

Remarks[edit | edit source]

Smart internationalization for ASP.NET page

The benefit of this approach is that you don't have to clutter controllers and other classes with code to look up values from .resx files. You simply surround text in [[[triple brackets.]]] (The delimiter is configurable.) An HttpModule looks for a translation in your .po file to replace the delimited text. If a translation is found, the HttpModule substitutes the translation. If no translation is found, it removes the triple brackets and renders the page with the original untranslated text.

.po files are a standard format for supplying translations for applications, so there are a number of applications available for editing them. It's easy to send a .po file to a non-technical user so that they can add translations.

Basic configuration and setup[edit | edit source]

  1. Add the I18N nuget package to your MVC project.
  2. In web.config, add the i18n.LocalizingModule to your <httpModules> or <modules> section.
<!** IIS 6 -->
  <add name="i18n.LocalizingModule" type="i18n.LocalizingModule, i18n" />

<!** IIS 7 -->
    <add name="i18n.LocalizingModule" type="i18n.LocalizingModule, i18n" />
  • Add a folder named "locale" to the root of your site. Create a subfolder for each culture you wish to support. For example, /locale/fr/.
  • In each culture-specific folder, create a text file named messages.po.
  • For testing purposes, enter the following lines of text in your messages.po file:
#: Translation test
msgid "Hello, world!"
msgstr "Bonjour le monde!"
  • Add a controller to your project which returns some text to translate.
using System.Web.Mvc;

namespace I18nDemo.Controllers
    public class DefaultController : Controller
        public ActionResult Index()
            // Text inside [[[triple brackets]]] must precisely match
            // the msgid in your .po file.
            return Content("[[[Hello, world!]]]");
  • Run your MVC application and browse to the route corresponding to your controller action, such as [[yourportnumber/default]].

Observe that the URL is changed to reflect your default culture, such as


  • Replace /en/ in the URL with /fr/ (or whatever culture you've selected.) The page should now display the translated version of your text.
  • Change your browser's language setting to prefer your alternate culture and browse to /default again. Observe that the URL is changed to reflect your alternate culture and the translated text appears.
  • In web.config, add handlers so that users cannot browse to your locale folder.
<!** IIS 6 -->
    <add path="*" verb="*" type="System.Web.HttpNotFoundHandler"/>

<!** IIS 7 -->
    <remove name="BlockViewHandler"/>
   <add name="BlockViewHandler" path="*" verb="*" preCondition="integratedMode" type="System.Web.HttpNotFoundHandler"/>