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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T00:51:17+00:00 2026-05-27T00:51:17+00:00

I have a screen to create records in MVC. If the model validates then

  • 0

I have a screen to create records in MVC. If the model validates then I want to return back to my Home screen. I have seen the following:

                return new RedirectToRouteResult(
                    new RouteValueDictionary(
                        new { controller = "Access", action = "Home" }
                    )
                );

This seems rather overkill as it specifies the controller and I don’t want to change controllers. Is there a simpler way to do this?

  • 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-27T00:51:18+00:00Added an answer on May 27, 2026 at 12:51 am

    The default route looks like this in global.asax:

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

    That means that the "Home" controller will be used if none has been specified (as in http://yoursite/). The default action is "Index" (as in http://yoursite/somename/).

    Redirect to site home page

    With this knowledge we can use RedirectToRoute to visit the home page of the site and the controller. Let’s start with the controller:

    return RedirectToRoute("Default");
    

    Redirect to default action of a controller

    If we want to get to the default action for a controller, we can either use the action name directly as in:

    return RedirectToAction("Index");
    

    or specify the controller in RedirectToRoute:

    return RedirectToRoute("Default", new { controller = "somename" });
    

    But that would generate duplicated code in each controller, so let’s move the code to our BaseController instead:

    public ActionResult RedirectToHome()
    {
        return RedirectToRoute("Default", new { controller = RouteData.Values["controller"] });
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have the following table: $sql = CREATE TABLE received_queries ( sender_screen_name varchar(50), text
I have the following html/css code . When I have the screen resolution to
I have a screen with a ListBox of items. The item template contains an
I have a screen with pivot functionality, and I'd very much like just one
I have a screen with two RadioButtonField objects. By default, the first RadioButtonField shows
i have a screen with multiple little widgets (all with different divs around them).
I have a screen with a webView in my navigation controller stack and when
I have a screen where you can enable/disable modules for my Android application. For
In an embedded program I have a screen object that needs to manage a
I sometimes need to use Visual Studio when I have limited screen real estate

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.