ASP.NET MVC - Wordpress Style URLs

ASP.NET MVC - Wordpress Style URLs

Wordpress is very highly regarded and proven to follow good practise which in turn facilitates rankings with search engines.

One proven factor is the seo freindly urls. Such as the examples below; 

Lets say that we have two controllers, each with their won actions;

View/BlogPost View/BlogCategory Contact/Form Contact/Post 

The wordpress view engine is flexible enough that the test url can resolve to BlogPost and the another url can resolve to BlogCategory.

Does anyone know if this is possible in MVC and is it feasible? Im thinking about a custom 404 handler that would preserve the url in the browser and then fire the required actions.



ELMAH in mvc2
You define a route in the global.asax like this, the bottom one being the default:.
can anybody give me an idea? about this exception handling
        routes.MapRoute(             "Test",             "test",             new { controller = "View", action = "BlogPost"}         );          routes.MapRoute(             "Another",             "another",             new { controller = "View", action = "BlogCategory"}         );          routes.MapRoute(             "Default", // Route name             "{controller}/{action}/{id}", // URL with parameters             new { controller = "Home", action = "Index", id = UrlParameter.Optional } // Parameter defaults         ); 
The second parameter in MapRoute() is the URL, in your case "test" and "another".

How to redirect the Error page in mvc
You can probably see here, that you can store this route data somewhere else, like a db, then foreach through them adding each one to the RouteCollection.. MVC custom routing

Calling cached data (in service layer) from an ASP.NET MVC View - what other alternative do we have?

Issue with HTML5 audio control in Visual Studio 2010 and ASP.NET MVC


Setting the UpdateCheck.Never mode by default in Visual Studio 2010 DBML designer (MS SQL/ASP.NET MVC)
You could add an Action to your controller, with a RedirectToAction() call.

public ActionResult test() { return RedirectToAction("BlogPost"); } ..

public ActionResult another() { return RedirectToAction("BlogCategory"); } ...


As other guys answered above it's easy to have such routes to have friendly "Slug" URLs.

There are also some tricks to build pretty clean URLs like WordPress.

I have written two blog posts on this topic which may help you have a better understanding of Slug URLs: Build pretty clean URL for your dynamic pages using JavaScript and Translating your content title using Google Translate API to use in a URL.

97 out of 100 based on 77 user ratings 1027 reviews