Theme-Logo
  •   .Net
    •   C Sharp(C#)
    •   Web API
    •   Micro Services
    •   ASP.Net
    • ASP.Net MVC
    • .Net Core
  •   Database
    • SQL Server
    • Oracle
    • PostgreSQL
  •   jQuery
    • jQuery Tutorials
    • jQuery Plugins
    • jQuery UI
    • More on jquery
  •   Tutorials
    • Microservices Tutorials
    • DotNet Core Tutorials
    • PostgreSql Tutorials

Routing in ASP.Net MVC

Routing is not specific to the MVC framework. It can be used with ASP.NET Webform application or MVC application. ASP.NET introduced Routing to eliminate the needs of mapping each URL with a physical file. Routing enables us to define a URL pattern that maps to the request handler.

Configure a Route

Every MVC application must configure (register) at least one route configured by the MVC framework by default. You can register a route in RouteConfig class, which is in RouteConfig.cs under App_Start folder. The following figure illustrates how to configure a route in the RouteConfig class .

DotNet Palace : MVC Routing

Route Constraints

You can also apply restrictions on the value of the parameter by configuring route constraints. For example, the following route applies a limitation on the id parameter that the id's value must be numeric.

DotNet Palace : MVC Routing

Register Routes

After configuring all the routes in the RouteConfig class, you need to register it in the Application_Start()event in the Global.asax so that it includes all your routes into the RouteTable.

DotNet Palace : MVC Routing

Trending Post
What is Anonymous methods in C#.
Why Is It A Bad Idea To Throw Your Own Exceptions.
How's The DLL Hell Problem Solved In .net?
Interview Questions and Answers
Describe the Async method of C#?
Is it possible to serialise hashtables?
Explain the differences between “out” and “ref” parameters in C#?
How would you implement the Singleton design pattern in C#?
What Are The Ways To Deploy An Assembly?
What Are Advantages And Disadvantages Of Microsoft-provided Data Provider Classes In Ado.net?
About us

DotNet Palace is a community platform created and maintained by The articles are mainly focused on Microsoft stack technologies like C#, ASP.Net, MVC, .Net Core, SQL Server and Oracle, PostgreSQL, SQLite etc. To improve the site's content you can send your valuable suggestions at info.dotnetpalace@gmail.com

Quick links
  • SOLID Principles
  • Questions
  • OOPS Principles
  • DotNet Palace Tutorials
  • Privacy Policy
  • Terms and Condition