开发者

MVC routing problems - url generation

I what to create a url that looks like website.com/sea/season/23/team

Here is the MapRoute

routes.MapRoute(
  "SeaTeam", 
  "sea/season/{seasonId}/team/{action}/{name}", 
  new { controller = "Team", action = "Index", name = UrlParameter.Optional } 
); 

The Html.ActionLink looks like

@Html.ActionLink("Add Team", "Index", "SeaTeam", new { seasonId = seasons.id }, null)

But its generating the following url

<a href="/SeaTeam?seasonId=1">Add Team</a>

Any insights?开发者_StackOverflow Thanks...

Update

Here is the controller

public class TeamController : Controller
{
    //
    // GET: /Team/

    public ActionResult Index()
    {
        //get the seasons of the loged user
        var loadedTeam = tempFunctions.getSeasonsOf(CustomHelper.UserGuid(User.Identity.Name));
        return View("Team/ManageTeam", loadedTeam);
    }


try:

@Html.ActionLink(
    "Add Team", // linkText
    "Index", // Action
    "Team", // Controller
    new { seasonId = seasons.id }, 
    null)

I don't see a SeaTeam Controller

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜