Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Configuration for route localization in ASP.NET MVC app
namespace RouteLocalizationDemo
using System.Collections.Generic;
using System.Web.Mvc;
using System.Web.Routing;
using RouteLocalization.Mvc;
using RouteLocalization.Mvc.Setup;
using Controllers;
public class RouteConfig
/* Public static methods */
public static void RegisterRoutes(RouteCollection routes)
const string DefaultCulture = "en";
ISet<string> acceptedCultures = new HashSet<string>() { "en", "de" };
var configuration = new Configuration
DefaultCulture = DefaultCulture,
AcceptedCultures = acceptedCultures,
AttributeRouteProcessing = AttributeRouteProcessing.AddAsNeutralAndDefaultCultureRoute,
AddCultureAsRoutePrefix = true
var localization = new Localization(configuration);
.ForAction(x => x.About())
.ForAction(x => x.Contact())
CultureSensitiveHttpModule.GetCultureFromHttpContextDelegate = Localization.DetectCultureFromBrowserUserLanguages(acceptedCultures, DefaultCulture);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.