Asp.net mvc 4 路线赢得';不匹配 应用程序
我有一个视图,其中包含一个客户列表,对于给定的公司,如果指定了CoId,则所有已注册的客户都会出现在列表中。HanlderId只表示谁在处理客户机。该列表被分页(因此是page参数)并排序,因此在下面的代码中有sortField和sortDir。除了路线,一切都正常。所以 安装程序 我有一个区域注册文件,路径如下:Asp.net mvc 4 路线赢得';不匹配 应用程序,asp.net-mvc-4,Asp.net Mvc 4,我有一个视图,其中包含一个客户列表,对于给定的公司,如果指定了CoId,则所有已注册的客户都会出现在列表中。HanlderId只表示谁在处理客户机。该列表被分页(因此是page参数)并排序,因此在下面的代码中有sortField和sortDir。除了路线,一切都正常。所以 安装程序 我有一个区域注册文件,路径如下: context.MapRoute( "Companies_Clients", "Companies/Clients/P
context.MapRoute(
"Companies_Clients",
"Companies/Clients/Page/{page}/{sortField}/{sortDir}/{HandlerId}/{CoId}",
new
{
controller = "MyController",
action = "Index",
CoId = -1,
HandlerId = -1,
page = 1,
sortField = "ClaimId",
sortDir = "ASC",
AccidentDate = UrlParameter.Optional,
DateOfBirth = UrlParameter.Optional,
ClientSurname = UrlParameter.Optional,
InvoiceNumber = UrlParameter.Optional
}
);
默认为UrlParameter的参数。可选的是搜索参数(也可以搜索列表)
我在MyController中有一个操作定义如下:
public virtual ActionResult Index(
Nullable<int> FeId = -1,
Nullable<DateTime> AccidentDate = null,
Nullable<DateTime> DateOfBirth = null,
string ClientSurname = null,
Nullable<int> InvoiceNumber = null,
int page = 1, string sortField = "ClaimId", string sortDir = "DESC", int SolicitorId = -1)
{
var model = service.BuildModel(FeId, AccidentDate, DateOfBirth, ClientSurname, InvoiceNumber, page, sortField, sortDir, SolId);
return View("Index", model);
}
在某种程度上,与路由匹配的是我的mvcSiteMap节点:
<mvcSiteMapNode title="Clients" area="Companies" controller="MyController" action="Index" key="clients">
问题:
小问题是:
我做错了什么??为什么Html.ActionLink调用与路由不匹配??
另一个问题是:
为什么默认参数不出现在mvcsitemapnode生成的路由中?如果phil haacks route debugger还没有使用,我建议您彻底检查它。这让我省去了很多头疼的事。我一直在用它。我看不出路线不匹配的原因。
<mvcSiteMapNode title="Clients" area="Companies" controller="MyController" action="Index" key="clients">
/Companies/Clients/Page