3

I would like to know how to set up the routing in asp.net mvc so I can have similar urls to stackoverflows question urls?

Do you believe that ASP.Net MVC is ready for production?

I am guessing that for url creation there is a helper class that creates the question urls.

The part i am wondering is how this is implemented on the Controller side. I think that most probably the home controller has a questions action and the id is 115634. Then comes the title of the question - I guess this is for search engine optimization. My problem is how the controller method signature would look like.

Is it a Question(int? id) or Question(string? param) that contains both the id and the title?

How would one implement this?

Community
  • 1
  • 1
gyurisc
  • 11,234
  • 16
  • 68
  • 102

2 Answers2

5

Check out this question where Jeff Atwood himself posts the code they use to make the friendly URL. Also, I am not a C# developer so I am not sure how things work on ASP.NET MVC, but if you try and remove the title in a StackOverflow URL, the page works anyways. They are 100% for readability for humans (so they know what to expect when they see the link) and for search engines. As such I would expect if you want something similar you make it an optional param in the controller.

Community
  • 1
  • 1
Paolo Bergantino
  • 480,997
  • 81
  • 517
  • 436
  • Actually, search engines are largely smart enough not to care anymore- at least not as much. It's more to make it somewhat human-readable. – Joel Coehoorn Mar 03 '09 at 17:31
  • Do you have a source for this? Last I've heard, Google cares quite a bit if a search term matches something in the URL. But yes, they are also for the benefit of humans. Added this. – Paolo Bergantino Mar 03 '09 at 17:32
  • http://stackoverflow.com/questions/505793/do-seo-friendly-urls-really-affect-a-pages-ranking – Joel Coehoorn Mar 03 '09 at 17:38
  • The answer you refer to currently shows outdated code. Jeff updated his original post with a new version: http://stackoverflow.com/questions/25259/how-do-you-include-a-webpage-title-as-part-of-a-webpage-url/25486#25486 – Tom Lokhorst Mar 03 '09 at 17:50
  • If Jeff Atwood himself post the code then the that should be the answer! :) – gyurisc Mar 05 '09 at 04:52
0

check out this question...may be the answer you're looking for (:

Community
  • 1
  • 1
Kieron
  • 26,748
  • 16
  • 78
  • 122