---
title: "A route named 'DefaultApi' is already in the route collection"  
description: "A route named 'DefaultApi' is already in the route collection"  
author: "Pravesh Singh"  
published: 2014-12-02  
updated: 2014-12-03  
canonical: https://www.mindstick.com/forum/12732/a-route-named-defaultapi-is-already-in-the-route-collection  
category: "asp.net mvc"  
tags: ["asp.net", "mvc", "url routing"]  
reading_time: 1 minute  

---

# A route named 'DefaultApi' is already in the route collection

This [question](https://www.mindstick.com/blog/23175/how-to-solve-neet-question-paper-in-less-time) may seems [duplicate](https://www.mindstick.com/forum/160911/sql-query-to-find-duplicate-records-in-a-table-in-sql-server) but this is slightly different. In all other question in SO I had noticed that they have [multiple](https://www.mindstick.com/blog/12797/iowa-is-expected-to-see-heavy-growth-in-multiple-sectors) routes registered. but in my case I have just one route.

I am creating [asp.net](https://www.mindstick.com/articles/934/default-folders-available-inside-the-asp-dot-net-application-folder) [webapi](https://www.mindstick.com/forum/12745/how-do-i-use-webapi-rest-correctly-when-other-params-are-needed) ([framework](https://www.mindstick.com/forum/34615/software-framework-vs-library) 4.5) and have just one route in [RegisterRoutes](https://www.mindstick.com/forum/12655/registerroutes-not-working-in-mvc5)() [method](https://www.mindstick.com/forum/166/webservice-method) -

```
    public static void RegisterRoutes(RouteCollection routes)    {        routes.IgnoreRoute("{resource}.axd/{*pathInfo}");         routes.MapRoute(            name: "DefaultApi",            url: "rest/{controller}/{id}",            defaults: new { id = UrlParameter.Optional }        );     }
```

Then why is it throwing error?

A route named 'DefaultApi' is [already](https://yourviews.mindstick.com/view/88453/the-hidden-ways-ai-is-already-controlling-your-daily-life) in the route collection. Route names must be unique. [Parameter](https://www.mindstick.com/blog/450/parameter-class-in-c-sharp) name: name

## Replies

### Reply by Anonymous User

Instead of adding it in the route collection, added it in HttpConfiguration

```
       
config.Routes.MapHttpRoute(            name:"DefaultApi",           
routeTemplate: "rest/{controller}/{id}",            defaults:new { id = RouteParameter.Optional }        );
```


---

Original Source: https://www.mindstick.com/forum/12732/a-route-named-defaultapi-is-already-in-the-route-collection

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
