我正在尝试创建这条路线:
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
如果有错误网址(帖子的最新网址)的正确网址(帖子的第一个网址),我该怎么办?
提前感谢您的帮助
答案 0 :(得分:2)
您使用@Html.ActionLink()
的错误重载。为html属性(最后一个参数)指定null
时需要使用this overload
@Html.ActionLink("My Link", "Reporting", "Reporting", new { area = "Admin", reportName = "reportingName" }, null)