views:

26

answers:

1

Hi,

I'd like to track an id in the route if it's possible? This is pretty much what I want:

/groups/{id} - Show group
/groups/{id}/forum/topic/{id} - Show forum topics for the group
/groups/{id]/calendar/ - Show the calendar for the group

As you see I want to keep track of what group the user is in by the url, instead of let's say a cookie.

Thanks!

A: 

Have you defined {id} in your routes, e.g.:

routes.MapRoute(
    "", 
    "groups/{id}/forum/topic/{topicId}",
    new { controller = "Forum", action = "Topic" });

And into your controller:

public class ForumController : Controller
{
    public ActionResult Topic(int id, int topicId)
    {

    }
}

It's not really clear how you want to track it....

Matthew Abbott
I'm completely new to mvc so perhaps I should have studied some more before asking. It seems all I need to do is that when I create a link I keep passing the groupid (first {id} above). Now I'm just wondering how I can get the groupid within a view, to pass it on to for example ActionLink.
ZNS