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 247273
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 11, 20262026-05-11T21:14:33+00:00 2026-05-11T21:14:33+00:00

I have started converting my simple website to ASP.NET MVC, just to mess around

  • 0

I have started converting my simple website to ASP.NET MVC, just to mess around with it. I have a switch language feature on there that basically sets the Session[“language”] to another language and refreshes the page. Please correct me if this could be done better, but I have made two controllers for this and setting the session in there. The problem is the routing at the end. Could I refresh the page in some neat way, or can I get the current Action and re-route it to that? Or is this more a scenario for Ajax?

Thankful for advice!

  • 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-11T21:14:33+00:00Added an answer on May 11, 2026 at 9:14 pm

    is there any reason why you are using the session variable? a more common solution is to include the language code in the route, i.e. blah.com/en/info or blah.com/jp/info (for english and japanese)

    if you did this every page on the site could contain links to each language. if you are writing a publicly accessible site this would also make it easier for google to index all your content.

    this article explains how to include the language in the domain, ie. en.blah.com or jp.blah.com: http://blog.maartenballiauw.be/post/2009/05/20/ASPNET-MVC-Domain-Routing.aspx

    UPDATED: Here’s a simple example of including the language code in the URL route.

    Change the default route to include a language parameter:

    routes.MapRoute(
    "Default", 
    "{language}/{controller}/{action}/{id}", 
    new { language = "en", controller = "Home", action = "Index", id = "" }
    );
    

    Add links for each language to your masterpage:

    <li><%= Html.ActionLink(
        "Spanish", 
        ViewContext.RouteData.Values["action"].ToString(), 
        new { language = "es" })%></li>
    <li><%= Html.ActionLink(
        "French", 
        ViewContext.RouteData.Values["action"].ToString(), 
        new { language = "fr" })%></li>
    <li><%= Html.ActionLink(
        "English", 
        ViewContext.RouteData.Values["action"].ToString(), 
        new { language = "en" })%></li>    
    

    These will render as links back to the page you are on – only with the language changed.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm just getting started with Ruby on Rails development and I have a question
I have started creating a simple product image carousel. It basically comprises of 3
I have started following Test Driven Development and find it very logical and helps
I have started to convert a code on my site to jquery from mootols
I have started to do some programming using VIM. I have very mixed feelings
I am doing a simple ajax call with the YahooUI Javascript library as follows:
I have an application that I am working on modifying and I am having
I need to create a fairly complicated layout for a widget in Expression Blend,
I am connecting to a MS SQL server through SQL Alchemy, using pyodbc module.
I'm working on a project that has a lot of legacy C code. We've

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.