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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 5, 20262026-06-05T23:43:10+00:00 2026-06-05T23:43:10+00:00

I have a request controller that is getting out of hand, and I want

  • 0

I have a request controller that is getting out of hand, and I want to divide the actions on several controllers while maintaining a clean URL. I’m trying to experiment with routing, but without success. I’ve read some examples and tutorials on routing, but, though I understand the examples, nothing seems to apply to my case, and I feel non the wiser. What I want is for the URL Requests/Approval to be handled on my ApprovalController instead of my RequestController, so I wrote the following.

public static void RegisterRoutes(RouteCollection routes)
    {
        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

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

        routes.MapRoute(
            "Approval",
            "Request/{controller}/{action}",
            new { controller = "Approval", action="Index", id = "" }
        );

    }

But it’s not working. Why? I have a folder in the my Views called Approval, and in there I have a file called Index.cshtml. How should I code the MapRoute?

Edit

I added all the routes I’ve got

  • 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-05T23:43:11+00:00Added an answer on June 5, 2026 at 11:43 pm

    You need to swap the two MapRoute statements, like so:

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

    The reason it is currently not working is because the first statement (‘Default’ route name) is getting matched before the second one is even evaluated.

    In addition (as noted in my above example,) you need to remove ‘{controller}’ in the Approval route and replace with ‘Approval’… unless you specifically want the URL /Request/{ANY controller}/{action} to go through, which I doubt. From your question it seems you only want /Request/Approval/ to go to your Approval controller.

    Don’t forget to keep the Default route at the bottom, so as to match your other controllers and actions. It serves as a catch-all should no other matches exist.

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

Sidebar

Related Questions

I have a controller (Spring-MVC) that generates a PDF report on a get request.
Suppose I have an events controller. If I request /events by GET it will
I have this in my Controller. public function delete($id) { if($this->request->is('get')) { throw new
I have an object in my controller @data=<meta property=\og:url\ content=\<%=SITE_URL%><%=request.request_uri%>\ />.html_safe When I print
Possible Duplicate: Create an alert on any view controller after Facebook request:didFailWithError: I have
Is there a way to force the request router to disambiguate controller actions based
The functionality I want is this: I have a set of URLs that I
I have a controller that handles file uploads. Ultimately I would like to be
I have a JSON request that check to the server if a username has
I have just started using OutputCache on some of my controller actions and I

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.