---
title: "How to make clean url in mvc 4?"  
description: "How to make clean url in mvc 4?"  
author: "Anurag Sharma"  
published: 2015-02-21  
updated: 2015-02-21  
canonical: https://www.mindstick.com/forum/12972/how-to-make-clean-url-in-mvc-4  
category: "asp.net mvc"  
tags: ["url routing", "routing"]  
reading_time: 2 minutes  

---

# How to make clean url in mvc 4?

Hi I’m want to create [simple](https://yourviews.mindstick.com/story/1469/5-simple-ways-to-stay-fit-amp-healthy) blog for clean url I like to use [routing](https://www.mindstick.com/articles/11998/attribute-routing-in-asp-dot-net-mvc) in my app.

I added to RouteConfig.cs this code:

```
public class RouteConfig        {            public static void RegisterRoutes(RouteCollection routes)            {                routes.IgnoreRoute("{resource}.axd/{*pathInfo}");                 routes.MapRoute(                    name: "Default",                    url: "{controller}/{action}/{id}",                    defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }                );                 routes.MapRoute(                    name: "ArticleList",                    url: "Articles/{category}/{page}",                    defaults: new                    {                        controller = "Articles",                        category = UrlParameter.Optional,                        page = 1                    });            }        }
```

And if I write in [web browser](https://www.mindstick.com/blog/301688/best-web-browsers-for-2023) url:

http://localhost:6666/[Articles](https://www.mindstick.com/articles/12872/how-to-write-articles-of-50-and-more-a-day-quick-and-easy)/SomeCategory/3

I want to move to this [controller](https://www.mindstick.com/blog/273/passing-values-from-controller-to-view-in-asp-dot-net-mvc):

```
public class ArticlesController : ControllerBase<IHomeService>        {            public ActionResult Index(string category, int page = 0)            {                return View("~/Views/Article/Articles.cshtml");            }         }
```

with [parameters](https://www.mindstick.com/articles/87/passing-parameters-in-c-sharp) category = "SomeCategory" and page = 1.

All I recieve is [Server](https://www.mindstick.com/articles/43769/what-is-serverless-architecture-is-it-worth-switching-over) [Error](https://yourviews.mindstick.com/view/88527/fixing-quickbooks-error-4120-reinstalling-vs-repairing) in '/' Application. The [resource](https://www.mindstick.com/blog/43433/top-best-resources-for-women-about-beauty-and-health) cannot be found.

What is wrong?

## Replies

### Reply by David Miller

Hi try this code:

```
routes.MapRoute(            name: "ArticleList",            url: "{controller}/{category}/{page}",            defaults: new            {                category = UrlParameter.Optional,                page = 1,                action = "Index"            },            constraints: new            {                controller = "Articles"            }       );              routes.MapRoute(                name: "Default",                url: "{controller}/{action}/{id}",                defaults: new { controller = "Home", action = "Index", id = UrlParameter.Optional }            );
```


---

Original Source: https://www.mindstick.com/forum/12972/how-to-make-clean-url-in-mvc-4

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
