tags:

views:

90

answers:

3

I am on the home page:

http://localhost/

http://localhost/Home (yeah, this one too, though I don't like it)

I have a foreach loop, looping through my categories. I want the Html.ActionLink to point to:

http://localhost/site/{category-name}

I currently have:

Html.ActionLink(cat.cat_name, "site", "", new { id = cat.cat_name}, null)

This points to:

http://localhost/Home/site/{cat_name}

I want to get rid of the Home.

EDIT

No matter what page I am on, I want the link to point to:

    http://localhost/site/{category-name}
A: 

Got it. Added a new route:

    routes.MapRoute(
        "site",                                              // Route name
        "site/{id}",                           // URL with parameters
        new { controller = "Site", action = "Index", id = "" }  // Parameter defaults
    );

ActionLink:

<%= Html.ActionLink(cat.cat_name, "index", new {controller = "Site", action = "index", id = cat.cat_name}) %>

Not sure why I need the "index", but it works.

Martin
+1  A: 

You don't need specific route. Just use string HtmlHelper.RouteLink(string linkText, object routeValues) helper:

<%= Html.RouteLink(cat.cat_name,
    new { controller = "Site", action = "Index", id = cat.cat_name }) %>
eu-ge-ne
+2  A: 

Not sure i follow the question 100% but it looks like you are using the default route and the home controller? if this is the case then you would want to change your route and or the controller you are using.

YetAnotherDeveloper