asp.net mvc中的路由为我提供了长度
我正在尝试创建以下路线:asp.net mvc中的路由为我提供了长度,asp.net,asp.net-mvc,asp.net-mvc-4,asp.net-mvc-routing,Asp.net,Asp.net Mvc,Asp.net Mvc 4,Asp.net Mvc Routing,我正在尝试创建以下路线: http://localhost:28790/Admin/Reporting/Reporting?reportName=MyReportName 要访问此控制器,请执行以下操作: public ActionResult Reporting(string reportName){...} 为此,我在以下区域添加了此路由: context.MapRoute( "Admin_Reporting", "Admi
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(文章的第一个URL)取代错误的URL(文章的最新URL),我该怎么做
提前感谢您的帮助您使用了错误的
@Html.ActionLink()
重载。当为html属性(最后一个参数)指定null
时,需要使用
您使用了错误的重载。它需要是
@Html.ActionLink(我的链接,“报告”,“报告”,new{area=“Admin”,reportName=“reportingName”},null)
(null
是Html属性)arghh我知道我忘了什么!谢谢你,伙计!回答这个问题,我会验证它!
@Html.ActionLink("My Link", "Reporting", "Reporting", new { area = "Admin", reportName = "reportingName" }, null)