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

  • Home
  • SEARCH
  • 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 8743079
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T11:36:46+00:00 2026-06-13T11:36:46+00:00

I have an MVC website which used to use URLs in the standard format

  • 0

I have an MVC website which used to use URLs in the standard format of: Controller/Action.

Recently, I have changed it to: Site/Controller/Action.

The problem is, there are several links to my site out there which follow the old format, and I want to redirect them accordingly.

for example: mydomain.com/Home/CustomerSearch now should go to mydomain.com/Online/Home/CustomerSearch

whereas: mydomain.com/AffiliatesHome/CustomerSearch now should go to mydomain.com/Affiliate/AffiliatesHome/CustomerSearch

How can I get it to handle the redirecting by putting in the extra routing, depending on the link they came in by?

The current routing I am using is:

 routes.MapRoute(
      "Default", // Route name
      "{site}/{controller}/{action}/{id}",              
      new {site="IS", controller = "Home", action = "Index", id = UrlParameter.Optional }
   );
  • 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-06-13T11:36:46+00:00Added an answer on June 13, 2026 at 11:36 am

    Since I do not really see an schema in your old to new URL mapping I would suggest to add routes that match the old Controller/Action Schema and map them to the new Site/Controller/Action route schema.

    So you could add the following routes

    routes.MapRoute(
       "LegacyHome", 
       "Home/{action}/{id}", 
       new { site="Online", controller = "Home", action = "Index", id = UrlParameter.Optional } 
    );
    
    routes.MapRoute(
      "LegacyAffiliates", 
      "AffiliatesHome/{action}/{id}", 
      new { site="Affiliate", controller = "AffiliatesHome", action = "Index", id = UrlParameter.Optional } 
    );
    

    From an SEO standpoint this is not ideal because you have different URLs for the same page. A permanent redirect via status code 301 and the new URL passed in the location is better suited.

    You could build a redirect controller and use the legacy routes to map legacy URLs to the redirect controller somehow like this

    routes.MapRoute(
               "LegacyHome",
               "Home/{newAction}/{id}",
               new { controller = "Redirect", action = "Redirect", newSite = "Online", newController="Home", newAction = "Index", id = UrlParameter.Optional }
            );
    

    Code of the redirect controller

        public class RedirectController : Controller
    {
        public ActionResult Redirect(string newSite, string newController, string newAction)
        {
            var routeValues = new RouteValueDictionary(
                new
                    {
                        site = newSite,
                        controller = newController,
                        action = newAction
                    });
    
            if (RouteData.Values["id"] != null)
            {
                routeValues.Add("id", RouteData.Values["id"]);
            }
    
            return RedirectToRoutePermanent(routeValues);
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have an ASP MVC 3 website which is used on the intranet. It
I have an ASP.net MVC website which I used dotnetopenauth for to allow log
I have an MVC application which is my marketing website, and two other regular
I have a website on with MVC, which has a dropdown in the masterpage.
I'm currently writing a website in ASP.NET MVC, and my database (which doesn't have
I have an ASP.NET MVC web site. I have many actions which require authentication
I have built a MVC website on IIS6. I used the built-in ASP.NET Security
I program website with MVC 3.0 which uses EntityFrame work 4.0, In controller layer
In my current project, we have to create a website (ASP.NET MVC) which is
I have a website built in asp.net mvc 3 which uses the repository pattern

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.