---
title: "What is URL routing in MVC?"  
description: "What is URL routing in MVC?"  
author: "Anonymous User"  
published: 2020-01-22  
updated: 2020-01-22  
canonical: https://www.mindstick.com/forum/155723/what-is-url-routing-in-mvc  
category: "asp.net mvc"  
tags: ["asp.net mvc"]  
reading_time: 2 minutes  

---

# What is URL routing in MVC?

[Please explain](https://www.mindstick.com/forum/344/hi-rohith-i-am-new-for-mvc-please-explain-how-to-set-implicitly-isauthenticated-true) me about [URL](https://www.mindstick.com/forum/436/url-redirection) [routing in MVC](https://www.mindstick.com/forum/12971/how-to-change-url-using-url-routing-in-mvc) with example and some figure.

## Replies

### Reply by Nishi Tiwari

- [Routing](https://www.mindstick.com/articles/11998/attribute-routing-in-asp-dot-net-mvc) is defined as the pattern matching system which handles the incoming request and finds out what to do with that requests.
- At runtime, Routing engine uses the **[Route table for matching the incoming](https://www.mindstick.com/forum/155716/what-is-url-rewriting-iis)** request’s URL pattern to the URL patterns defined in the Route table.
- In Convention based routing, you need to define routes in the routing table. It helps you to keep URL clean and avoid database IDs in URL. \ For example, instead of ‘http://www.mindstick.com/forum/155738/what-is-validation-in-[mvc](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc)’, we have ‘https://www.mindstick.com/forum/155739/define-viewbag-in-mvc’
- It adds the advantage of being more ‘search robot’ friendly and which is good for SEO.
- We just need to register this route table in Application_Start (Global.asax) using this code.

```
RouteConfig.RegisterRoutes(RouteTable.Routes);
```

**How routing fits in an MVC application.**

![What is URL routing in MVC?](https://www.mindstick.com/mindstickforums/0f10e174-2df6-4630-b666-be4b76c6fe2f/images/e328af02-2a3f-410c-a62e-d17c94ae6e52.png) **\**

## There are two type of routing in MVC

- Convention based routing
- Attribute-based routing(introduced in MVC 5)

## Convention based routing:

- Route templates are define in the webApiConfig level.
- These routing templates works for the whole controller of the application.
- Can we create our custom routes only?

In below figure, the default method that add routes to the route table which is located in the RouteConfig.cs file in the App_Start folder.

![What is URL routing in MVC?](https://www.mindstick.com/mindstickforums/0f10e174-2df6-4630-b666-be4b76c6fe2f/images/b689a6d2-53c7-4882-b24c-5399bef58dbb.png)\

In the above image, we can see three things: “routes”, “IgnoreRoute” and “MapRoute”.

**Routes** : It is nothing but only a table which is a collection of routes defined in the routing table. When anyone hits some URL in the browser, an application first checks the existing route tables and match with routes.

- IgnoreRoute: It is a collection of URL which should be ignored by the application.
- MapRoute: It is used to add a new route to the routing table.

## Attribute-based routing

- Route templates are defined in the Controller Level or action level.
- This routing template works only for those places where they define such as controller level or action level.
- It is best suited for the rest full application


---

Original Source: https://www.mindstick.com/forum/155723/what-is-url-routing-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
