I am trying to send 2 variables to my controller with a Html.Actionlink, but everytime i do this, i get a NULL value, instead of the value i am trying to send.
This is my Html.Actionlink:
<ul>
@{ Spot selectedSpot = (Spot)Session["SelectedSpot"];}
@foreach (Spot spot in (List<Spot>)Session["AllSpots"])
{
if (selectedSpot != null)
{
if (selectedSpot.Id == spot.Id)
{
<li>@Html.ActionLink(spot.ToString(), "SetSpot", "EmsUser", new { selectedSpot = spot, user = Model }, new { @class = "selected"})</li>
}
else
{
<li>@Html.ActionLink(spot.ToString(), "SetSpot", "EmsUser", new { selectedSpot = spot, user = Model }, null)</li>
}
}
else
{
<li>@Html.ActionLink(spot.ToString(), "SetSpot", "EmsUser", new { selectedSpot = spot, user = Model }, null)</li>
}
}
</ul>
This is my controller:
public ActionResult SetSpot(Spot selectedSpot, User user)
{
Session["SelectedSpot"] = selectedSpot;
user.SetId(0);
return View("MakeReservation", user);
}
EDIT:
This is what the actionlink expects from me. "EmsUser" is the controller name and "SetSpot" is the action name