---
title: "how to route the controller to a different name"  
description: "how to route the controller to a different name"  
author: "Pravesh Singh"  
published: 2014-09-20  
updated: 2014-09-20  
canonical: https://www.mindstick.com/forum/2257/how-to-route-the-controller-to-a-different-name  
category: "asp.net mvc"  
tags: [".net", "asp.net mvc"]  
reading_time: 1 minute  

---

# how to route the controller to a different name

Have a really basic thing to do - I need to expose a post API such as [mobile](https://www.mindstick.com/articles/310668/reasons-why-you-should-choose-custom-mobile-app-development-for-your-business)/api/pswdrec which I wanna bind to my PasswordController to avoid that dull name.

It's a [webapi](https://www.mindstick.com/forum/12745/how-do-i-use-webapi-rest-correctly-when-other-params-are-needed) with areas and I'm trying both [Attribute Routing](https://www.mindstick.com/interview/34238/how-does-routing-work-in-asp-dot-net-mvc-explain-attribute-routing) and MapHttpRoute. neither works so far.

```
 public class PasswordController : MobileApiControllerBase{    //[Route("api/mobile/pswdrec/")]    public RestResponseMessage Post(UserCredentialsModel credentials)    {        return RestResponseMessage.OK();    }}
```

Checked the [client side](https://www.mindstick.com/forum/160418/what-are-the-best-practices-for-securely-storing-bearer-tokens-on-the-client-side) and the requests are proper json requests. It's [starting](https://www.mindstick.com/blog/12024/things-you-need-to-know-when-starting-your-own-business) to work when I simply change the name of the [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc) to PswdrecController.

Is there any other way to "[rename](https://www.mindstick.com/interview/23303/how-to-rename-extention-of-mdf-file)" the controller?

## Replies

### Reply by Sumit Kesarwani

Hi Pravesh, \
try this:\

config.Routes.MapHttpRoute(

name: "MyCustomRouteApi",

routeTemplate: "api/{controller}/{id}",

defaults: new { controller = "mobile", action = "pswdrec", id = RouteParameter.Optional}

);


---

Original Source: https://www.mindstick.com/forum/2257/how-to-route-the-controller-to-a-different-name

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
