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;

www.myblog.com/test www.myblog.com/another www.myblog.com/contact 

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.


MEF and ASP.NET MVC

1:

ELMAH in asp.net 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 asp.net mvcYou must probably see here, this you must store this route data any where else, like a db, then foreach through them adding each one to the RouteCollection.. Asp.net 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

2:

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"); } ... 

3:

As another guys answered above it's easy to have such routes to have friendly "Slug" URLs. There are also any tricks to build pretty clean URLs like WordPress. I have written two blog posts on this topic which may guidance 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 72 user ratings 707 reviews

@