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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 15, 20262026-06-15T20:07:27+00:00 2026-06-15T20:07:27+00:00

I have a button in Layout page, which is supposed to navigate between different

  • 0

I have a button in Layout page, which is supposed to navigate between different views.

<a id="next" href="/Navigation?CurrentPage=@ViewBag.CurrentPage">Next</a>

I populate ViewBag.CurrentPage value in ViewModel of each page.

Navigation controller intercepts anchor click in following controller –

public class NavigationController : Controller
{
    public void Index(string CurrentPage)
    {
        PageType currentPageEnum = (PageType)Enum.Parse(typeof(PageType), CurrentPage);
        PageType nextPageEnum = currentPageEnum + 1;
        RedirectToAction(nextPageEnum.ToString());            
    }
}

Enum contains ActionNames in sequential order, so just increment currentPageEnum value to find next page.

enum PageType
{
    Page1,
    Page2
}

Each action has a mapping route in Global.asax.cs as below –

routes.MapRoute("Page1", "Page1", new { controller="controller1", action="Page1"});
routes.MapRoute("Page2", "Page2", new { controller="controller2", action="Page2"});

Question:
I have not been able to redirect to other controllers with this code-

RedirectToAction(nextPageEnum.ToString()); 

Request terminates without redirect.

  1. What info am I missing.
  2. Is there a better efficient way to navigate
    between diffrent views, in ASP MVC

Thanks!

  • 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-15T20:07:28+00:00Added an answer on June 15, 2026 at 8:07 pm

    Add a return statement and make the function return something.

    
    public class NavigationController : Controller
    {
        public ActionResult Index(string CurrentPage)
        {
            PageType currentPageEnum = (PageType)Enum.Parse(typeof(PageType), CurrentPage);
            PageType nextPageEnum = currentPageEnum + 1;
            return RedirectToAction(nextPageEnum.ToString());            
        }
    }
    

    And since you refer to a mapped route name and not an action I believe you need RedirectToRoute instead of RedirectToAction like in this code:

    
    public class NavigationController : Controller
    {
        public ActionResult Index(string CurrentPage)
        {
            PageType currentPageEnum = (PageType)Enum.Parse(typeof(PageType), CurrentPage);
            PageType nextPageEnum = currentPageEnum + 1;
            return RedirectToRoute(nextPageEnum.ToString());            
        }
    }
    

    But I would suggest that the best way to navigate in an MVC environment from the (razor)view is like this:

    <div>
        @Html.ActionLink(string linkText, string actionName)
    </div>
    

    If the action is in the same controller. If not use this overload:

    <div>
        @Html.ActionLink(string linkText, string actionName, string controllerName)
    </div>
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have in my layout a button, which is has to change image when
I have an html/css page that is supposed to use an html table layout
I have a layout which contains button and textView with visibility=gone. This layout is
Typical search layout having RelativeLayout, TextView, EditText and Button I have a.9.png image having
I have a Linear Layout that has a Button and a TextView on it.
I have to add a custom layout in a relative layout on a button
I have a linear layout with several buttons in it. The button images are
I have a listView, where each row has a button in the row layout.
I have 4 buttons in my layout - they are switchers between 4 possible
I'd like to have X number of Ajax panels on my list page which

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.