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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T13:55:53+00:00 2026-05-26T13:55:53+00:00

I am using asp.net mvc 2 and create localization based on routes. my route

  • 0

I am using asp.net mvc 2 and create localization based on routes.

  1. my route looks like: {culture}/{controller}/{action}
  2. I go to my home controller: en/Home/Index
  3. my home controller view have a links to other controllers:

    <a href='<%= Url.Action("Prods","Products") %>' >Products</a>
    <a href='<%= Url.Action("Index","About") %>' >About</a>
    

First link generated code: /en/Products/Prods but second one generate: /Home/Index

I can’t understand why Url.Action skips the {culture} route parameter when I pass value Index in argument action? What am I doing wrong?

Route configuration:

routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

routes.MapRoute("Login", // Route name
                "{controller}/Index", // URL with parameters
                new { controller = "Login", action = "Index" } // Parameter defaults
                ).RouteHandler = new SingleCultureMvcRouteHandler();

routes.MapRoute("Default", // Route name
                "{controller}/{action}/{id}", // URL with parameters
                new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults
               );      

Then

foreach (Route r in routes)
{
    if (!(r.RouteHandler is SingleCultureMvcRouteHandler))
    {
       r.RouteHandler = new MultiCultureMvcRouteHandler();

       r.Url = "{culture}/" + r.Url;

       if (r.Defaults == null)
       {
          r.Defaults = new RouteValueDictionary();
       }

       r.Defaults.Add("culture", "en");

       if (r.Constraints == null)
       {
          r.Constraints = new RouteValueDictionary();
       }

       r.Constraints.Add("culture", new CultureConstraint(cultures));
    }
 }

Thanks for all help

  • 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-26T13:55:54+00:00Added an answer on May 26, 2026 at 1:55 pm

    When generating URL your best options is to always use the route names because this way you do not get into the subtleties of the algorithm used to select the route that will be used to generate the URL.

    My advice if for you not to use Url.Action and instead use Url.RouteUrl which allows you to specify the name of the route that should be used to construct the URL.

    By always using route names you also make your code more robust to changes, for example, you can add new routes without having to worry that they might break your existing code for URL generation.

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

Sidebar

Related Questions

Using ASP.NET MVC when I create my model, then a controller based on the
I create a dropdown list by using ASP.NET MVC helper like this, <%=Html.DropDownList(Group,-please select
I am using ASP.NET MVC 2 Beta. I can create a wizard like workflow
I am using ASP.Net MVC along with Jquery to create a page which contains
I need to create a web application using ASP.NET MVC, jQuery and web standards
Say you create a form using ASP.NET MVC that has a dynamic number of
what is the preferred practice when linq2sql using (in asp.net mvc applications): to create
I am using FckEditor in Create.aspx page in asp.net mvc application. Since I need
I am trying to create a custom authentication scheme in ASP.NET MVC using form
I'm using MVC 1.0 and have created a RequireSSLAttribute (like the one in ASP.NET

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.