Pregunta

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

¿Fue útil?

Solución

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.

Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top