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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T05:32:54+00:00 2026-05-29T05:32:54+00:00

I have inherited from a very small ASP.NET WebForms project, and my customer would

  • 0

I have inherited from a very small ASP.NET WebForms project, and my customer would like to add a second language to it.

For every “somepage.aspx”, I’d like to support a “second language path” version of it, like “fr/somepage.aspx”. I’d like to handle this using normal globalization (CurrentCulture + resource files in both languages) and avoid having to duplicate each page. I must keep the original paths valid, thus I have excluded ASP.NET MVC for now (for lack of knowing if I could continue to support “.aspx” paths).

Is this possible?

  • 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-29T05:32:54+00:00Added an answer on May 29, 2026 at 5:32 am

    URL Routing is avalaible in for ASP.NET.

    You could create two routes, the first being the route that catches your language:

    {language}/{page}

    The second route would be just

    {page}

    In MVC we can create route constraints that would enforce the Language to be of a specific value (so like en, en-us, etc) I’m not positive if the same can be done in regular ASP.NET WebForms routing.

    Here are two articles that describe the topic of routing in WebForms (non-MVC)

    http://msdn.microsoft.com/en-us/magazine/dd347546.aspx

    and

    http://weblogs.asp.net/scottgu/archive/2009/10/13/url-routing-with-asp-net-4-web-forms-vs-2010-and-net-4-0-series.aspx

    EDITED TO ADD CODE SAMPLE

    In my Global.asax I registered the following:

        void RegisterRoutes(RouteCollection routes)
        {
            routes.Ignore("{resource}.asxd/{*pathInfo}");
            routes.Add(
                new Route(
                    "{locale}/{*url}", //Route Path
                    null, //Default Route Values
                    new RouteValueDictionary{{"locale", "[a-z]{2}"}}, //constraint to say the locale must be 2 letters. You could also use something like "en-us|en-gn|ru" to specify a full list of languages
                     new Utility.Handlers.DefaultRouteHandeler() //Instance of a class to handle the routing
                ));
    
        }
    
    
        void Application_Start(object sender, EventArgs e)
        {
            // Code that runs on application startup
            RegisterRoutes(RouteTable.Routes);
    
        }
    

    I also created a seperate Class (see asp.net 4.0 web forms routing – default/wildcard route as a guide.)

    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Web;
    using System.Web.Compilation;
    using System.Web.Routing;
    using System.Web.UI;
    
    namespace SampleWeb.Utility.Handlers
    {
        public class DefaultRouteHandeler:IRouteHandler
        {
            public IHttpHandler GetHttpHandler(RequestContext requestContext)
            {
                //Url mapping however you want here: 
    
                string routeURL = requestContext.RouteData.Values["url"] as string ;
    
                string pageUrl = "~/" + (!String.IsNullOrEmpty(routeURL)? routeURL:""); 
    
                var page = BuildManager.CreateInstanceFromVirtualPath(pageUrl, typeof(Page))
                           as IHttpHandler;
                if (page != null)
                {
                    //Set the <form>'s postback url to the route 
                    var webForm = page as Page;
                    if (webForm != null)
                        webForm.Load += delegate
                        {
                            webForm.Form.Action =
                            requestContext.HttpContext.Request.RawUrl;
                        };
                }
                return page;
            }
        }
    }
    

    This works because when no locale is specified in the URL the default view engine for Web Forms takes over. It also works when a 2 letter locale (en? us? etc) is used. In MVC we can use an IRouteConstraint and do all kinds of checking, like making sure the locale is in a list, checking to see if the path exists, etc but in WebForms the only option for a constraint is using a RouteValueDictonary.

    Now, I know there is an issue with the code as-is, default documents don’t load. So http://localhost:25436/en/ does not load the default document of default.aspx, but http://localhost:25436/en/default.aspx does work. I’ll leave that to you to resolve.

    I tested this with sub directories and it works.

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

Sidebar

Related Questions

I have inherited a project that uses the following pattern for passing parameters from
I just inherited a very old ASP.NET 2.0 web application. In the application it
I have inherited a project from a client, who believes he has all the
I am very new to InstallShield and have inherited a InstallScript project. I have
I have inherited a very messy project. There are at least 3 versions that
I have CustomForm inherited from Form which implements a boolean property named Prop .
I have inherited some code (from zip file) from a developer and git initialzed,
I have inherited a application framework from the previous developer where I now work.
I have inherited a few programs from a previous developer who was a little
i have inherited a database application from someone else and there are a few

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.