T4MVC @Url.Action(MVC.Controller.Action()) Renders “?Area=” Parameter in QueryString

后端 未结 2 1707
眼角桃花
眼角桃花 2020-12-14 08:20

I am rendering a menu from a Partial Action directly to the layout, using:

@Html.Action(MVC.Menu.Index())

This action, determines which Men

2条回答
  •  感动是毒
    2020-12-14 08:50

    Something strange is going on here, and I wonder if there is some kind of MVC bug at the root. Even without using T4MVC, this happens if you write:

    @Html.ActionLink("Welcome", "Index", "Home", new { Area = "" }, null)
    

    In a regular view, this doesn't generate the bogus ?Area=, while in a Html.Action call it does. I need to ask someone on the team.

    For now, you can workaround by deleting this line (around line 310) in t4mvc.tt:

    <# if (MvcVersion >= 2) { #>result.RouteValueDictionary.Add("Area", area ?? "");<# } #> 
    

提交回复
热议问题