AdBlock Detected

We provide high-quality source code for free. Please consider disabling your AdBlocker to support our work.

Buy me a Coffee

Saved Tutorials

No saved posts yet.

Press Enter to see all results

Routing System Assembly Location in MVC

By pushpam abhishek
Listen to this article
Routing System Assembly Location in MVC
google 

Routing System is commonly used for MVC. However, it was designed to be used with standard ASP.NET projects or WebForms. It is the main reason for Routing System Assembly to be located in System. Web and not strictly in System.Web.MVC. Assembly name that is being added to your MVC project, when you create it for the first time, is called System.Web.Routing. However, the System. The web is enough for Routing System to work with your project.

Routing applies not just to MVC and WebForms but to all other aspects of the ASP.NET platform. It is designed to be versatile in what it can do. Routing System is designed to be generic and it does not aware of Controllers/Actions in MVC Framework. It is designed to pass segments of URL to the Request pipeline. Any ASP.NET application can use this request pipeline for intended purposes.

Routers generally defined in Global.asax file and .NET MVC Project template set up this file with Routers entries for you by default.


Example of Global.axas routers method used in MVC.NET

 public static void RegisterRoutes(RouteCollection routes)

        {

            routes.IgnoreRoute("{resource}.axd/{*pathInfo}");

            routes.MapRoute(

                "Default", // Route name

                "{controller}/{action}/{id}", // URL with parameters

                new { controller = "User", action = "Index", id = UrlParameter.Optional } // Parameter defaults

            );

        }
Another way of setting up Routing for ASP.NET application other than MVC is as follows:


public static void RegisterRoutes(RouteCollection routes)

        {

            Route myRoute = new Route("{controller}/{action}", new MvcRouteHandler());

            routes.Add("MyRoute", myRoute);
        }

Actually, Routers are set up in Global.asax.cs file and not purely in Global.asax. However, it is common to refer to Routers being part of the Global.asax file.

Share this post

pushpam abhishek

About pushpam abhishek

Pushpam Abhishek is a Software & web developer and designer who specializes in back-end as well as front-end development. If you'd like to connect with him, follow him on Twitter as @pushpambhshk

Comments