I've searched and found several questions similar to mine, but the answers are too specific to the OP's situation to help.
On my Main view, I have a table of items and action links for each of those items:
Item Name Actions
Item #1 Foo | Bar
Item #2 Foo | Bar
The Main view displays this table with the following code:
@foreach (var item in Model)
{
<tr>
<td>@Html.DisplayFor(modelItem => item.Title)</td>
<td>
@Html.ActionLink("Foo", "Index", "Test", item, null) |
@Html.ActionLink("Bar", "Index", "Test", item , null)
</td>
</tr>
}
As you can see, each item in the Main view's table links to the Test controller/view.
The Test controller's Index action is defined as:
public ActionResult Index(Item item)
{
return View(item);
}
The Test view is then defined to accept the Item model:
@model Models.Item
This all works and the Test view displays the Item object's data.
However, I now need Foo and Bar to display the Test controller/view in two distinct ways, or modes.
Something like:
?mode=foo&item=Item
?mode=bar&item=Item
How do I pass both the Item object and a mode to my Test controller so that the Test view will behave appropriately based on the mode?