title: Display Model info in a View MVC5 without DB Context
body: <p>so I'm new to MVC5 and I'm creating a website without the use of a DB context. How do I go about displaying Model info taken from fields into a view? I cannot use a DB context which would've made this a whole lot easier. </p>
  
  <p>Here's my Controller:</p>
  
  <pre><code>using SaasSocialNetwork.Models;
  using SSN.Shared.Interfaces;
  using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using System.Web.Security;
  using log4net;
  
  namespace SaasSocialNetwork.Controllers
  {
  public class OpportunitiesController : Controller
  {
  
      ILog logger = LogManager.GetLogger(typeof(OpportunitiesController));
      //
      // GET: /Opportunities/
      public ActionResult Index(OpportunityModel opportunity)
      {
  
          List&lt;OpportunityModel&gt; opportunities = new List&lt;OpportunityModel&gt;();
          opportunities.Add(opportunity);
  
          try
          {
               //multishops = TownBL.getMultishops().ToList();
               return View(opportunities);
          }
          catch(Exception ex)
          {
              logger.Error(ex);
              TempData["Warnning"] = ex.Message;
              return View(opportunities);
          }
          finally
          {
                 logger.Debug("&lt;&lt;Index");
          }
          //return View();
      }
  
  
      // GET: /Opportunities/Details/5
      public ActionResult Details(OpportunityModel opportunity)
      {
          logger.Debug("&gt;&gt;Details");
          try
          {
              //MultiShops multishop = TownBL.getMultishops().Single(m =&gt; m.ID == id);
              //logger.InfoFormat("{0} Multi Shop Details", opportunity.Name);
              //var list = new List&lt;string&gt; { "test1", "test2", "test3" };
              return View("Details", opportunityModel);
          }
          catch (Exception ex)
          {
              logger.Error(ex);
              return View("Details");
          }
          finally
          {
              logger.Debug("&lt;&lt;Details");
          }
          return View();
      }
  
  
      // GET: /Opportunities/Create
      public ActionResult Create()
      {
          logger.Debug("&gt;&gt;Create(GET)");
          try
          {
  
  
              return View("Create");
  
          }
          catch (Exception ex)
          {
              logger.Error(ex);
              return View("Index");
          }
          finally
          {
              logger.Debug("&lt;&lt;Create");
          }
          //return View();
      }
  
      //
      // POST: /Opportunities/Create
      [HttpPost]
      public ActionResult Create(OpportunityModel opportunity)
      {
          try
          {
              // TODO: Add insert logic here
              OpportunityModel object1 = new OpportunityModel();
              SSN.Shared.Interfaces.Opportunity opp = new Opportunity();
  
              opp.Name = object1.Name;
              opp.Description = object1.Description;
              opp.ImageUrl = object1.ImageUrl;
              opp.GuidID = object1.GuidID;
  
              return RedirectToAction("Index");
          }
          catch
          {
              return View();
          }
      }
  
      //
      // GET: /Opportunities/Edit/5
      //public ActionResult Edit(Guid GuidId)
      //{
      //    logger.Debug("&gt;&gt;Edit(GET)");
      //    try
      //    {
      //        //MultiShops opportunity = TownBL.getMultishops().Single(m =&gt; m.ID == id);
      //        ViewBag.state = new List&lt;SelectListItem&gt;{
  
      //                         new SelectListItem { Text = "Active", Value = "Active" },
      //                         new SelectListItem { Text = "Suspended", Value ="Suspended"},
      //                    };
      //        //return View(opportunity);
      //    }
      //    catch (Exception ex)
      //    {
      //        logger.Error(ex);
      //        return View();
      //    }
      //    finally
      //    {
      //        logger.Debug("&lt;&lt;Edit");
      //    }
      //}
  
      //
      // POST: /Opportunities/Edit/5
      [HttpPost]
      public ActionResult Edit(OpportunityModel opportunity)
      {
          logger.Debug("&gt;&gt;Edit(GET)");
          try
          {
              if (ModelState.IsValid)
              {
                  //TownBL.UpdateMultiShop(multishop);
                  logger.InfoFormat("Opportunity {0} Updates", opportunity.Name);
              }
  
              TempData["Sucess"] = "Opportunity Sucessfully Updated";
              return RedirectToAction("Index");
          }
          catch (Exception ex)
          {
              logger.Error(ex);
              TempData["Warnning"] = "Error Updating Opportunity";
              return View();
          }
          finally
          {
  
              logger.Debug("&lt;&lt;Edit(POST)");
          }
      }
  
      //
      // GET: /Opportunities/Delete/5
      //public ActionResult Delete(Guid GuidId)
      //{
      //    logger.Debug("&gt;&gt;Delete(GET)");
      //    try
      //    {
      //        //MultiShops opportunity = TownBL.getMultishops().Single(m =&gt; m.ID == id);
      //        TempData["Sucess"] = "Opportunity Sucessfully Deleted";
      //        //return View(opportunity);
      //    }
      //    catch (Exception ex)
      //    {
      //        logger.Error(ex);
      //        TempData["Warnning"] = "Error Deletting Opportunity";
      //        return View("Index");
      //    }
      //    finally
      //    {
      //        logger.Debug("&lt;&lt;Delete(GET)");
      //    }
      //}
  
      //
      // POST: /Opportunities/Delete/5
      [HttpPost]
      public ActionResult Delete(OpportunityModel opportunity)
      {
          logger.Debug("&gt;&gt;Delete(POST)");
          try
          {
  
              //TownBL.DeleteMultiShop(multishop.ID);
              logger.InfoFormat("{0} Opportunity Deleted", opportunity.Name);
              return RedirectToAction("Index");
          }
          catch (Exception ex)
          {
              logger.Error(ex);
              return View();
          }
          finally
          {
              logger.Debug("&lt;&lt;Delete(POST)");
          }
      }
  }
  </code></pre>
  
  <p>}</p>
  
  <p>My Model:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Collections.ObjectModel;
  using System.ComponentModel.DataAnnotations;
  using System.Linq;
  using System.Web;
  using System.Web.Security;
  
  
  namespace SaasSocialNetwork.Models
  {
      public class OpportunityModel
      {
          public Guid GuidID { get; set; }
          [Required(ErrorMessage = "Enter ID")]
          [StringLength(50)]
          [RegularExpression("^[0-9a-zA-Z ]+$", ErrorMessage = "ID must be alphanumeric")]
          public string Id { get; set; }
  
          [Required(ErrorMessage = "Enter Name")]
          [StringLength(50)]
          [RegularExpression("^[0-9a-zA-Z ]+$", ErrorMessage = "Name must be alphanumeric")]
          public string Name { get; set; }
  
          [Required(ErrorMessage = "Enter Network ID")]
          [StringLength(50)]
          [RegularExpression("^[0-9a-zA-Z ]+$", ErrorMessage = "ID must be alphanumeric")]
          public string NetworkId { get; set; }
  
          [Required(ErrorMessage = "Enter Description")]
          public string Description { get; set; }
  
          [Required(ErrorMessage = "Enter image URL")]
          public string ImageUrl { get; set; }
  
          /// &lt;summary&gt;
          ///  This is the name of the organization
          /// &lt;/summary&gt;
          [Required(ErrorMessage = "Enter the organization name")]
          [StringLength(50)]
          [RegularExpression("^[0-9a-zA-Z ]+$", ErrorMessage = "Name must be alphanumeric")]
          public string Organization { get; set; }
  
      }
  
  }
  </code></pre>
  
  <p>And the view I wish to populate:</p>
  
  <pre><code>@model IEnumerable&lt;SaasSocialNetwork.Models.OpportunityModel&gt;
  
  @{
      ViewBag.Title = "Index";
      Layout = "~/Views/Shared/_Layout.cshtml";
  }
  
  &lt;h2&gt;Index&lt;/h2&gt;
  
  &lt;p&gt;
      @Html.ActionLink("Create New", "Create")
  &lt;/p&gt;
  &lt;table class="table"&gt;
      &lt;tr&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.GuidID)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Name)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.NetworkId)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Description)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.ImageUrl)
          &lt;/th&gt;
          &lt;th&gt;
              @Html.DisplayNameFor(model =&gt; model.Organization)
          &lt;/th&gt;
          &lt;th&gt;&lt;/th&gt;
      &lt;/tr&gt;
  
      @foreach (var item in Model)
      {
          &lt;tr&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.GuidID)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Name)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.NetworkId)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Description)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.ImageUrl)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.DisplayFor(modelItem =&gt; item.Organization)
              &lt;/td&gt;
              &lt;td&gt;
                  @Html.ActionLink("Edit", "Edit", new { id = item.Id }) |
                  @Html.ActionLink("Details", "Details", new { id = item.Id }) |
                  @Html.ActionLink("Delete", "Delete", new { id = item.Id })
              &lt;/td&gt;
          &lt;/tr&gt;
      }
  
  &lt;/table&gt;
  </code></pre>