I created a view that worked successfully with 1 view
@model IEnumerable<string> <ul> @foreach (var fName in Model) { var name = fName; var link = @Url.Content("~/Content/archives/mgamm/") + name.Replace(" ", "%20"); <li style="list-style:none; font-size:1.2em;"> <a href="@link">@name</a> </li> } </ul> @if (User.IsInRole("admin")) { <div> @using (Html.BeginForm("Index", "Archives", FormMethod.Post, new { enctype = "multipart/form-data" })) { <input type="File" name="file" id="file" value="Choose File" /> <button type="submit">Upload</button> } </div> }
With controller
namespace plantationmvc.Controllers { public class ArchivesController : Controller {
However, I wanted to add another fragment like this on the same page, but with different content content.
How to add another model to this page?
I just had a controller and View, so I created a ViewModel by creating 2 classes
namespace plantationmvc.Models { public class ArchivesViewModel { public CommModel Model1 { get; set; } public MeetModel Model2 { get; set; } } public class CommModel { public IEnumerable<CommModel> } public class MeetModel { public IEnumerable<MeetModel> } }
When I try to pass this into my view as @model IEnumerable<plantationmvc.Models.CommModel> , it says that it does not exist in the namespace.
c # model-view-controller razor
teachtyler
source share