Best way to return list of tags? (programming)

Jul 15, 2009 at 11:18 PM

KiGG supports the return of stories with a specific tag (example provided the tag is valid. If the tag is invalid, a 404 custom error is returned. This is as expected.

If one sends the request one gets the same 404 error.

Looking at the code in StoryController.cs (line 247 in version 2.2), one finds:

        public ActionResult Tags(string name, int? page)
            name = name.NullSafe();

            if (string.IsNullOrEmpty(name))
                return RedirectToRoute("Published");

This would seem to indicate that all published stories should be returned rather than a 404. Is this a bug??
In any case, what I would like to have happen is to simply return a list of all Tags. I would also like to do the same thing for Categories (as an aside, if one looks at line 90 in StoryController.cs,
 the same possible bug appears for categrories as tags).
What is the best way to go about this? Should I add a new route in RegisterRoutes.cs and create new controllers and views to return these lists or is it better to just use the Default route and modify StoryController.cs?
Jul 16, 2009 at 8:40 AM
Edited Jul 16, 2009 at 8:48 AM

No, it is not a bug but it is MVC and the way url routes are managed.
In KIGG, routes are defined in RegisterRoutes class.
When you enter, there is a route named "Detail" that matches it.
This route redirects to the action Detail in the controller Story and it searches for a story with the unique name "Tags"
It does not have anything to do with Tags.
If you enter, it will be the same looking for a story named " foo"
When you enter, he route "StoryList" ("{action}/{name}/{page}") is chosen
This one redirects you to the action you mentionned
To obtain the behavior you mentionned, I guess you should add specific routes
Do not forget to add them, in RegisterRoutes class, before the ones I mentionned
In MVC, first route encountered, first taken