I am passing this :

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

and I am getting in browser :

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

with Error Code :

The parameters dictionary contains a null entry for parameter 'Id' of non-nullable type 'System.Int32' for method 'System.Web.Mvc.ActionResult EditCRMRequest(Int32)' in 'ApricaCRMEvent.Controllers.CRM.CRMController'. An optional parameter must be a reference type, a nullable type, or be declared as an optional parameter. Parameter name: parameters

If I explicitly write this in browser it works fine:

http://something.com/CRM/EditCRMRequest?Id=3
有帮助吗?

解决方案

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)
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top