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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T19:43:21+00:00 2026-05-17T19:43:21+00:00

Given these routes: routes.MapRoute(Test, test, new { controller = Test, action = Index });

  • 0

Given these routes:

routes.MapRoute("Test", "test", new { controller = "Test", action = "Index" });
routes.MapRoute("Default", "{controller}/{action}/{id}", 
  new { controller = "Home", action = "Index", id = UrlParameter.Optional }
);

If I call RedirectToRoute(“Default”) from the Index action of the TestController it redirects to /test but I expected it to redirect to /

I checked the result of calling RedirectToRoute(“Default”) before returning it during a debugging session.

RedirectToRouteResult result = RedirectToRoute(“Default”);

It has a property RouteName with a value “Default” and a property RouteValues with no elements (Count = 0). I checked using Reflector, and null is passed internally as the RouteValueDictionary.

Again, I would expect that given the defaults for the route defined in my application, it would redirect to Index view on the HomeController.

Why doesn’t it redirect to /?

  • 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-17T19:43:21+00:00Added an answer on May 17, 2026 at 7:43 pm

    The RouteValueDictionary filled in to the current action is being used to fill in the Controller, Action, ID. This is usually the functionality you want and lets you do things like <%:Html.ActionLink("MyAction")%> without needing to specify your controller in a view.

    To force it to the complete fall back default just use:

    RedirectToRoute("default", null");

    The second argument is for your routevalues and by specifying it you override the preexisting values.

    However I would say the preferred way would be to have a Home route which will not take any parameters. This means your redirects will not need a load of nulls floating around and a call to RedirectToRoute("Home") is also nice and explicit.

    Edit

    This is a really old answer and as a couple of people have mentioned doesn’t seem to have been working for them. For what it’s worth I now don’t use this pattern and explicitly override controller and area when I need to break out. Not only does it apparently work better but when you come back to the code it’s good to see explicitly that you’re coming out of this context and mean to blank out certain routevalues.

    For the record I have also tended more towards named route based URL generation over convention based generation.

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

Sidebar

Related Questions

In my routes.rb file I have the following line: resource :users which gives me
I have a button_to that I want to perform a PUT action (there is
We have a classic VBScript default.asp page in the root of our site. (This
I'm trying to implement a small ASP.NET MVC site which interacts with another site.
This is a continuation of a couple of previous questions I've had. I have
could really use your help, understanding this complex rails issue I've been banging by
I'm trying to write a method that does the following: public class GridCounting {
I'm trying to setup an ajax-based website that loads a fragment of a webpage
I am using BeautifulSoup in a simple function to extract links that have all

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.