Question

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?

Was it helpful?

Solution

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.

OTHER TIPS

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

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top