inside my mvc razor view I'm getting list of objects and inside foreach loop I'm creating links like

@{ 
    var dday = @ViewBag.Day;     
}
@foreach (var a in Model)
{
   <li>
        @Html.ActionLink(a.Name, "ProcessAction", "Home", new { ss= @a.Id, dd= dday, cc= @a.Comp}, null)            
   </li>
}

on controller side I'm getting first two variables populated and third parameter as null even @a.Comp is populated in the moment of sending inside link.

On link mouse over I'm getting third argument as Domain.Comp

有帮助吗?

解决方案

You cannot transfer arbitrary objects as URL parameters. Restrict yourself to strings and numbers, dates can already be tricky.

In your case it looks like you should use: cc= @a.Comp.Id.

You should be able to retrieve the object serverside from its Id.

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top