I am trying to populate a view from a controller. Here is what I am trying to do. I am filling in a dictionary with data and then I am putting that data in a viewdata:
Dictionary<string, string> list = ExtractURL(content);
ViewData["List"] = list;
At the view side I am having this:
<ul>
<% foreach(var item in ViewData["List"] as Dictionary<string, string>) { %>
<li><% item.Value.ToString(); %></li>
<% } %>
</ul>
Now, everything runs ok, but at the end I am just getting the list without any data there. Check the screenshot for reference.
Can someone please maybe point me what am I doing wrong.
Thanks in advance, Laziale
You have a typo in your syntax, change
<% item.Value.ToString(); %>to<%= item.Value.ToString() %>Otherwise
ToStringwill be called but not written to the output stream.