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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:57:03+00:00 2026-05-26T18:57:03+00:00

Can someone please explain what the following function does. I am learning Asp.net MVC

  • 0

Can someone please explain what the following function does. I am learning Asp.net MVC and unable to understand which controller is called when and renders which view.

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

        //register custom routes (plugins, etc)
        var routePublisher = EngineContext.Current.Resolve<IRoutePublisher>();
        routePublisher.RegisterRoutes(routes);

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

This code is from nopCommerce source-code. I can’t understand the URL routing for this project

  • 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-26T18:57:03+00:00Added an answer on May 26, 2026 at 6:57 pm

    The logic for this is in the System.Web.Mvc.MvcHandler class, the System.Web.Mvc.DefaultControllerFactory class, and the System.Web.Mvc.ControllerActionInvoker class. .NET Reflector is your friend.

    Basically, the MVC framework:

    1. Uses reflection to get all the controllers in the application project.

    2. Then it does something like IEnumerable<string> controllerNames = controllerTypes.Select(controllerType => controllerType.Name.Replace("Controller",string.Empty));. It then tries to match the first path segment, {controller}, to one of these sanitized controller type names (case-insensitive).

    3. Then, it looks at this controller’s public methods that have a return type that is of type ActionResult or some derivative. It matches the method name to the second path segment, {action}, as the action method to be called.

    4. If the selected method has a parameter that is named id, then it matches the third path segment {id} to that value, and passes it to the method. Otherwise, the optional id parameter is ignored.

    5. If the ActionResult type that is returned is a derivative of ViewResultBase then the IViewEngine tries to locate a corresponding view in the project using whatever conventions have been specified for that view engine. The WebFormViewEngine, for example, looks in the project for ~/Views/{controller}/{action}.ascx, ~/Views/{controller}/{action}.aspx, ~/Views/Shared/{action}.ascx, ~/Views/Shared/{action}.aspx by default.

      • If you want to further understand how routing works in MVC, I would highly suggest Scott Gu’s article on MVC Routing.

      • As far as the IRoutePublisher method, that looks like a nopCommerce specific method that automatically registers additional routes specific to nopCommerce‘s configuration. If you are interested in how nopCommerce’s specific routing conventions work, you can download the source code from the nopCommerce codeplex page and do a search for its default IRoutePublisher implementation.

        • Update The default IRoutePublisher is here: http://nopcommerce.codeplex.com/SourceControl/changeset/view/7e34dd9d98f3#src%2fPresentation%2fNop.Web.Framework%2fMvc%2fRoutes%2fRoutePublisher.cs . Basically, it gets all implementations of IRouteProvider and registers their route definitions in order according to their priority.
        • The default route providers are: Nop.Web.Infrastructure.RouteProvider and Nop.Web.Infrastructure.UpgradeRouteProvider
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Can someone please explain what the & does in the following: class TEST {
Can someone please explain why the following doesn't work works: function displayResults(data) { $(#odNextPage).click(function()
Can someone please explain the following. I've scoured the net for ages trying to
I am learning javascript and can someone please explain the following code snippet for
Can someone please explain the following How was the first JDK release unit Tested?
Can someone please explain how to understand a logcat from an android force close.
The following is taken from the Yahoo CSS reset. Can someone please explain the
Can someone please help me understand the following: In the previous version of NHibernate
Can someone please explain the difference between the following methods to me? it should
Can someone please explain this to me? I have the following code: <form action=<?php

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.