asp.net mvc 中的路由给了我长度

routing in asp.net mvc gives me lenght

我正在尝试创建这条路线:

http://localhost:28790/Admin/Reporting/Reporting?reportName=MyReportName

为了访问这个控制器:

public ActionResult Reporting(string reportName){...}

为此,我在区域中添加了这条路线:

context.MapRoute(
                "Admin_Reporting",
                "Admin/Reporting/Reporting/{reportName}",
                new
                {
                    reportName = UrlParameter.Optional
                }
            );

而且我测试了这个 ActionLink

@Html.ActionLink(My Link, "Reporting", "Reporting", new { area = "Admin", reportName = "reportingName" })

但结果确实不是我所期望的:

http://localhost:28790/Admin/Reporting/Reporting?Length=9

我该怎么做才能让正确的URL(post的第一个URL)代替这个错误的URL(最新的URL 的 post) ?

在此先感谢您的帮助

您使用了 @Html.ActionLink() 的错误重载。为html属性(最后一个参数)指定null时需要使用this overload

@Html.ActionLink("My Link", "Reporting", "Reporting", new { area = "Admin", reportName = "reportingName" }, null)