1

我正在传递这个:

<%: Html.ActionLink("Edit", "EditCRMRequest", "CRM", new { Id = item.Id })%>

我正在浏览器中:

http://something.com/CRM/EditCRMRequest?Length=3

带有错误代码:

参数字典包含“ApricaCRMEvent.Controllers.CRM.CRMController”中方法“System.Web.Mvc.ActionResult EditCRMRequest(Int32)”的不可为空类型“System.Int32”的参数“Id”的空条目。可选参数必须是引用类型、可空类型或声明为可选参数。参数名称:参数

如果我在浏览器中明确编写它,它可以正常工作:

http://something.com/CRM/EditCRMRequest?Id=3
4

1 回答 1

5

Correct way:

<%: Html.ActionLink("Edit", "EditCRMRequest", "CRM", new { Id = item.Id },null)%>

No overload method like this:

Html.ActionLink(string text, string action, string controller, object routeValues)

If you write like above, Lenght=3 is represent "CRM". Controller name behave as routeValues

Correct method is:

Html.ActionLink(string text, string action, string controller, object routeValues, object htmlAttributes)
于 2013-02-04T13:26:05.197 回答