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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T08:36:49+00:00 2026-05-16T08:36:49+00:00

My current Routing rules are routes.IgnoreRoute({resource}.axd/{*pathInfo}); routes.MapRoute( Default, // Route name {controller}/{action}/{id}, // URL

  • 0

My current Routing rules are

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(
    "Admin", // Route name
    "Admin/{controller}/{action}/{id}", // URL with parameters
    new { controller = "Admin", action = "Index", id = UrlParameter.Optional } // Parameter defaults
);

I have several controllers that can only be accessed by the Admin. Currently I have a menu at:

/Admin/Index

Which lists a bunch of action links. Right now clicking any of those links redirects like this example:

/News/Index

But I need it to be like:

/Admin/News/Index

This current setup sort of works, but links on my homepage are being caught by the wrong rule and are going to, for example /Admin/Article/1 when they should be just /Article/1

I’ve searched StackOverflow for the answer, and found some that come close – but I still don’t understand routing well enough to make use of their answers. Any assistance is appreciated.

EDIT

Here are a collection of links from the homepage that are being caught by the routing rules incorrectly

<div id="menucontainer">

                <ul id="menu">              
                    <li><%: Html.ActionLink(" ", "About", "Home", null, new { ID = "AboutMHN" })%></li>
                    <li><%: Html.ActionLink(" ", "Products", "Home", null,  new { ID = "Products" })%></li>
                    <li><%: Html.ActionLink(" ", "HubLocator", "Home", null, new { ID = "HubLocator" })%></li>
                    <li><%: Html.ActionLink(" ", "ResellerProgram", "Home", null, new { ID = "ResellerProgram" })%></li>
                    <li><%: Html.ActionLink(" ", "ResellerLogin", "Home",  null, new { ID = "ResellerLogin" })%></li>
                    <li><%: Html.ActionLink(" ", "ContactUs", "Home", null, new { ID = "ContactUs" })%></li>
                </ul>                 

            </div>

Also, my Admin controller just has an index action. I have controllers for all of the other ‘Admin’ pages, for example my NewsController has actions for index, create, edit, delete, for listing all the news articles, and performing crud operations. Am I structuring this incorrectly?

My AdminController.cs

 [Authorize(Roles = "Administrator")]
    public class AdminController : Controller
    {
        //
        // GET: /Admin/

        public ActionResult Index()
        {
            return View();
        }


    }

The Admin/Index this returns contains a menu with ActionLinks just like

<li><%: Html.ActionLink("News Articles", "Index", "News") %></li>

My NewsController.cs has Actions for performing CRUD operations. I would like the url to be

Admin/News/Edit/5

Instead of

News/Edit/5
  • 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-16T08:36:50+00:00Added an answer on May 16, 2026 at 8:36 am

    I needed to use Areas.

    See: http://elegantcode.com/2010/03/13/asp-net-mvc-2-areas/

    I created a new Area called Admin, renamed my AdminController.cs to MenuController.cs and placed all of the required controllers and views inside of the Admin area folder. Inside the Admin area folder there is a file called AdminAreaRegistration.cs which contains

    public class AdminAreaRegistration : AreaRegistration
    {
        public override string AreaName
        {
            get
            {
                return "Admin";
            }
        }
    
        public override void RegisterArea(AreaRegistrationContext context)
        {
            context.MapRoute(
                "Admin_default",
                "Admin/{controller}/{action}/{id}",
                new { controller= "Menu", action = "Index", id = UrlParameter.Optional }
            );
        }
    }
    

    I had to add in the controller = “Menu” so that when you navigate to /Admin it will take you to /Admin/Menu/Index by default. Now any of my controllers in the area folder are accessible like /Admin/News/Edit/5 and so forth. Thanks for your attempts, I should have been more clear that I am an absolute MVC noob and didn’t know about Areas to begin with.

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

Sidebar

Related Questions

Hi I'm setting up admin routing in CakePHP. This is my current route: Router::connect('/admin/:controller/:action/*',
I have the following code in my application helper. route = ActionController::Routing::Routes.recognize_path(current_uri) controller =
In rails, I can get the name of the current controller via controller_name and
I am having problem with namespaced controller and routing. I have following namespaced route.
For my current routing, the following ruby on rails code: <%= link_to current_user.name, users_path(current_user)
Is there a way to retrieve the current routing action from a MVC request?
I've configured my routing.yml with my route: users: url: /users param: { module: user,
How do I get the current route in Symfony 2? For example, routing.yml :
I'm trying to specify routes (specifically, the root route), dependent on what the current
I'm looking to do something similar to this post: How to hide controller name

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.