Friday, December 24, 2010

Making the url seo friendly in Asp.net MVC

While performing search engine optimization on our online movie booking website GO4cinema.com  which is developed in asp.net mvc, i came across a few issues which i am now blogging about.

Scenario:

The movies details page of our website had the url www.go4cinema.com/movie/details/61, now the problem with such a url is:

  • No information about the movie is there in the url so we lose a big opportunity for search engine optimization.
  • Since we want our users to share this url with their friends, there too the url would be meaningless.
So if we included the movie name in the url then it would be friendly enough to both humans as well as any search engine.

Solution:

At first look the solution is simple, just put the name of the film in the url instead of the id, so the url becomes:

www.go4cinema.com/movies/details/august-15
Now this satisfies my earlier requirements but then another problem arises, what if the name of the movie name changes? You will get a 404 and there goes your user and the seo ranking!!!
So the optimum solution would be to include both the database id and the name in the url :
www.go4cinema.com/movie/details/61/august-15
Coding:
The current implementation looks like this:
image
We modify it to :
image
and also add the corresponding route in the Global.asax file before the default route:
image
I ran the application and Voila the url www.go4cinema.com/movie/details/61/august-15 works!!!…
P.S this is not the end of problems… Will update this blog with the next blog on the next problem and solution. Cheers!!!

1 comment: