Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 723513
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:07:00+00:00 2026-05-14T06:07:00+00:00

I have a site that supports localization. I would like to be able to

  • 0

I have a site that supports localization. I would like to be able to switch between English and French.

Let say the user is currently at URL:
http://www.example.com/**en**/Home

I would like to redirect to:
http://www.example.com/**fr**/Home

If the user click on a "French" link how to change the URL part to "fr" yet not change the "Home" part of the URL (basically I want preserve the current location of the user)

Hope my question makes sense! I’m probably missing something very basic?

EDIT: Kind of found a solution.

<%= Html.ActionLink("Français", ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["controller"].ToString(), new { culture = "fr" }, null)%>
<%= Html.ActionLink("English", ViewContext.RouteData.Values["action"].ToString(), ViewContext.RouteData.Values["controller"].ToString(), new { culture = "en" }, null)%>

This maintains the action/controller of the current URL. Maybe there’s a cleaner solution?

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:07:01+00:00Added an answer on May 14, 2026 at 6:07 am

    In your Global.asax

     routes.MapRoute(
       name: "LocalizedRoute",
       url: "{language}/{controller}/{action}/{id}",
       defaults:
         new
         {
           language= "fr",
           controller = "Home",
           action = "Index",
           id = UrlParameter.Optional 
         },
       constraints: new { language= @"[a-z]{2}" });
    

    And you can have access to the language with the variable language in your controller

    To generate a link:

    <%= Html.ActionLink("French", ViewContext.RouteData.Values["action"], new { language = "fr" }) %>
    

    And you can make a base class controller with this property:

    public string Language { get { return this.Routedata["language"]; } }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

We have a site that we would like our customers to embed in their
I have a site that will ultimately support 4 languages and 2 countries (US
I have a site that requires Windows Authentication the application obtains the credential from
I have a site that is using x509 client certificates (2 way SSL) to
I have a site that usually has news items at the top of the
I have a site that I've developed that makes decent use of Javascript, and
I have one site that is displaying html content that needs to be displayed
I have a site that I am currently working on in ASP.NET 2.0 using
We have a site that needs to (as part of our process) generate a
I have a site that uses a couple DropDownLists that are databound. I was

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.