我收到以下错误,我的默认路由参数为空。我在Controller中使用了相同的代码,该代码在URL中没有任何参数,并且工作正常。我知道我的自定义路由被调用,但我不明白为什么startIndex和pageSize在操作中显示为null。MVC路由参数为空
错误:
The parameters dictionary contains a null entry for parameter 'startIndex' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult ViewVcByStatus(System.String, Int32, Int32)' in 'AEO.WorkOrder.WebUI.Controllers.VendorComplianceController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter.
Parameter name: parameters
控制器:
public ActionResult ViewVcByStatus(string status, int startIndex, int pageSize) { ... }
路线:
routes.MapRoute("ViewVcByStatus", "ViewVcByStatus/{status}",
new
{
controller = "VendorCompliance",
action = "ViewVcByStatus",
startIndex = 0,
pageSize = WebConfigurationManager.AppSettings["PageSize"],
});
链接:
<a href="VendorCompliance/ViewVcByStatus?status=PROCESSED">
也试过这个环节产生了同样的错误:
<a href="VendorCompliance/ViewVcByStatus/PROCESSED">
你有其他可能匹配的路线吗?此外,该网址与您在此处显示的路线不符。 – DavidG
唯一的其他路线是默认路线。我也尝试过并获得了相同的结果。 –