开发者

MVC routing problems - url generation

开发者 https://www.devze.com 2023-02-02 07:23 出处:网络
I what to create a url that looks like website.com/sea/season/23/team Here is the MapRoute routes.MapRoute(

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

精彩评论

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

关注公众号