0

I declare a list in one ActionResult, add to it and pass it through a redirecttoaction to display but theres no data, where abouts is my syntax wrong? I've tested the list and there is data in it (the if statement is within a loop):

Redirect parts:

var list = new List<FailedView>();
if (Metric[1] == "Failed") { list.Add(new FailedView { domain = Metric[0], reason = Metric[2] });
return RedirectToAction("Complete", new { failedView = list } );
}

View ActionResult

public ActionResult Complete(List<FailedView> failedView)
{
return View(failedView);
}

Model

public class FailedView
{
    public string domain { get; set; }
    public string reason { get; set; }
}
}

View

@model List<Linkofy.Models.FailedView>

<table class="table">
<tr>
    <th>
        Domain
    </th>
    <th>
        Reason
    </th>
</tr>

@foreach (var item in Model)
{
    <tr>
        <td>
            @Html.DisplayFor(modelItem => item.domain)
        </td>
        <td>
            @Html.DisplayFor(modelItem => item.reason)
        </td>
    </tr>
}

Katie
  • 25
  • 6
  • Short answer - you cannot (and look at the url your generating to understand why) –  Mar 23 '18 at 09:35
  • Why are you using a list to pass *0 or 1* item? – Rafalon Mar 23 '18 at 09:38
  • @rafalon its inside a loop I just didn't want to clutter the question – Katie Mar 23 '18 at 09:44
  • @StephenMuecke ah I see, what would be the best way in which to pass the information, would it just be best to save it to a table and display the table and then delete it on leave? – Katie Mar 23 '18 at 09:45
  • Persist the data somewhere (database, Session etc) in the POST method, and get it again in GET method –  Mar 23 '18 at 09:47

0 Answers0