---
title: "How to create a attribute based routing in MVC?"  
description: "How to create a attribute based routing in MVC?"  
author: "Anupam Mishra"  
published: 2016-02-04  
updated: 2016-02-04  
canonical: https://www.mindstick.com/forum/33954/how-to-create-a-attribute-based-routing-in-mvc  
category: "asp.net"  
tags: ["c#", "asp.net", "asp.net mvc"]  
reading_time: 1 minute  

---

# How to create a attribute based routing in MVC?

Hi Everyone,\
I want to know how to create a [attribute](https://www.mindstick.com/blog/221/attributes-reflection) based [routing in MVC](https://www.mindstick.com/forum/12971/how-to-change-url-using-url-routing-in-mvc)? Please give me a solution.\
\
Thank you.\

## Replies

### Reply by Anupam Mishra

Attribute [Routing](https://www.mindstick.com/articles/11998/attribute-routing-in-asp-dot-net-mvc) is introduced in [MVC](https://www.mindstick.com/forum/155803/define-cache-profile-in-mvc) 5 that is the ability to add routes to the Route Table via attributes so that the route definitions are in close proximity to their corresponding actions. We will still populate the Route Table, but we will do it in a different manner.\

```
public class HomeController : Controller  {    [Route("Users/Index")] //Route: /Users/Index    public ActionResult Index() { ... }}
```

[Route] attribute specify a route to be added to the Route Table which maps to this action. The parameters to [Route]'s constructor are where the real functionality happens.\
The route attribute says that the "**GotoStatement**" can be invoked using the URL structure "Users/about".\

```
public class HomeController : Controller{       [Route("Users/Statement")]       public ActionResult GotoStatement()       {           return View();       }}
```


---

Original Source: https://www.mindstick.com/forum/33954/how-to-create-a-attribute-based-routing-in-mvc

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
