MVC3 VB.NET Razor view Application… I have a view that uses a for each loop to display all the available courses. Next to each of these I would like to place a Html link to download that courses class handout file. Problem is I have not found anything on any forums about assigning the value to the hyperlink dynamically since it will vary with every iteration of the for each loop. I have coded the model to hold the file name associated with each class. Below is a snippet from the view…
@For Each item In Model
Dim currentItem = item
Dim Handout = Path.Combine((AppDomain.CurrentDomain.BaseDirectory) + "CourseHandouts\") + currentItem.handoutFile1
@<tr>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.course_ref)
</td>
<td>
@Html.DisplayFor(Function(modelItem) currentItem.course_title)
</td>
<td>@Html.DisplayFor(Function(modelitem) currentItem.course_start)</td>
<td>@Html.DisplayFor(Function(modelitem) currentItem.course_end)</td>
<td id="Actions">
@Html.ActionLink("Details", "CourseDetails", New With {.id = currentItem.course_id})
</td>
<a href="@Handout">Course Handout</a>
</tr>
Next
Anyone have any ideas on how I could create a unique download link for each file???
You need to make the link point to a client-facing URL: