Is it possible to pass an object to a Controller? For example, I have ActionLink and I am pass the Model as Id.
@Ajax.ActionLink(
"Next",
"Step",
new { StepId = 2, id = Model },
new AjaxOptions { UpdateTargetId = "stepContainer" },
new { @class = "button" })
And the Controller has
public ActionResult Step(int StepId, object id)
{
}
How can I do this? Is this silly?
No, you cannot pass objects like this. An ActionLink helper generates an anchor tag which when clicked sends a GET request to the server. In this GET request you will have to include everything that you want the server to receive as part of the query string.
Another possibility is to only send the id of this model so that the controller action can fetch it back from the datastore from which it initially fetched it when rendering the page:
and in the controller action: