---
title: "How to achive MVC route with numbers"  
description: "How to achive MVC route with numbers"  
author: "Anonymous User"  
published: 2014-12-26  
updated: 2014-12-26  
canonical: https://www.mindstick.com/forum/12812/how-to-achive-mvc-route-with-numbers  
category: "asp.net"  
tags: ["c#", "asp.net mvc", "routing"]  
reading_time: 2 minutes  

---

# How to achive MVC route with numbers

I [am trying](https://answers.mindstick.com/qa/36834/which-two-programming-languages-should-i-master-in-if-i-am-trying-to-get-into-google-or-facebook) to [route](https://www.mindstick.com/interview/396/what-is-routed-event-in-wpf) an old [URL](https://www.mindstick.com/forum/436/url-redirection) that is domain.com/1024 to my [home page](https://answers.mindstick.com/qa/95562/how-do-i-change-the-safari-home-page-on-a-mac) in mvc.

I keep getting [resource](https://www.mindstick.com/blog/43433/top-best-resources-for-women-about-beauty-and-health) not found errors.

Here is my routeConfig

```
        routes.MapRoute(        name: "1024",        url: "{controller}/{action}",        defaults: new { controller = "Home", action = "Direct", id = UrlParameter.Optional }    );
```

**My [Controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc)**

```
    public ActionResult Direct()    {         return RedirectToAction("Index");    }
```

## Replies

### Reply by Anonymous User

Hi jay\
If you have your route definition before the default, for example:

```
routes.MapRoute(  name: "1024",  url: "{id}",  defaults: new { controller = "Home", action = "Direct" });routes.MapRoute(  name: "Default",  url: "{controller}/{action}/{id}",  defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional });
```

This will route (host):(port)/ to Index and (host):(port)/1024 to Direct where you can RedirectToAction("Index").\
For example a HomeController to demonstrate the point (This ONLY redirects 1024 to index):\

```
public class HomeController : Controller    {        //        // GET: /Home/        public ActionResult Index()        {            return View();        }        public ActionResult Direct(int? id)        {            if (id.HasValue && id.Value == 1024)            {                return RedirectToAction("Index");            }            else            {                return View();            }        }    }
```

This would redirect any id to index:\

```
public class HomeController : Controller    {        //        // GET: /Home/        public ActionResult Index()        {            return View();        }        public ActionResult Direct(int? id)        {            return RedirectToAction("Index");        }    }
```


---

Original Source: https://www.mindstick.com/forum/12812/how-to-achive-mvc-route-with-numbers

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
