title: Object reference not set to an instance of an object MVC
body: <p>this is my models:</p>
  
  <pre><code>public class Ressource
  {
      [Key]
      public int RessourceId { get; set; }
      public string TitreR { get; set; }
      public string Link { get; set; }
      public string Type { get; set; }
      public string Desc { get; set; }
      public int Position { get; set; }
      public int Rating { get; set; }
      public string Tags { get; set; }
      public int SectionId { get; set; }
      public int UserId { get; set; }
  
  }
  public class Section
  {
      [Key]
      public int SectionId { get; set; }
      public string Titre { get; set; }
      public String Tags { get; set; }
  
      public virtual ICollection&lt;Ressource&gt; Ressources { get; set; }
  
  }
  public class structure
  {
  
          public Ressource ress;
          public List&lt;string&gt; liste;
  
  }
  </code></pre>
  
  <p>In this view, I enter the resource's title (TitreR), a description (Desc) and I choose from a list of tags which ones I want to link with this resource as well as entering a tag:</p>
  
  <pre><code>@model Mocodis.Models.structure
  
  @{
      ViewBag.Title = "AjouterRessource";
  }
  
  &lt;h2&gt;AjouterRessource&lt;/h2&gt;
  
  @using (Html.BeginForm("AjouterRessource", "Home", FormMethod.Post))
  {
  @Html.AntiForgeryToken()
  @Html.ValidationSummary(true)
  
  &lt;fieldset&gt;
      &lt;input type="hidden" name="SectionId" value="@Model.ress.SectionId"  /&gt;
      &lt;legend&gt;Ressource&lt;/legend&gt;
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.ress.TitreR)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.ress.TitreR)
          @Html.ValidationMessageFor(model =&gt; model.ress.TitreR)
      &lt;/div&gt;
  
      &lt;div class="editor-label"&gt;
          @Html.LabelFor(model =&gt; model.ress.Desc)
      &lt;/div&gt;
      &lt;div class="editor-field"&gt;
          @Html.EditorFor(model =&gt; model.ress.Desc)
          @Html.ValidationMessageFor(model =&gt; model.ress.Desc)
      &lt;/div&gt;
  &lt;/fieldset&gt;
  }
      &lt;form id="orderProductForm219" name="orderProductForm219" method="post" &gt;
  &lt;b&gt;Choisir les mots clés:&lt;/b&gt; 
  &lt;br /&gt;&lt;br /&gt;
  
  
  @foreach (string s in @Model.liste)
  {
      &lt;input type="checkbox" name="tags[]" value="@s"&gt; @s&lt;br /&gt;
  }
  &lt;input type="text" name="tags" id="tags" value="" /&gt; 
  
  
      &lt;p&gt;
          &lt;input type="submit" value="Create" /&gt;
          &lt;input type="hidden" name="tag" value="tags" /&gt;
          &lt;input type="hidden" name="res" value="@Model.ress" /&gt;
      &lt;/p&gt;&lt;/form&gt;
  </code></pre>
  
  <p>(I didnt put the javascript for it)</p>
  
  <p>Finally the controllers are:</p>
  
  <pre><code>public ActionResult AjouterRessource(int SectionId)
      {
  
          Ressource res = new Ressource();
          res.SectionId = SectionId;
          Section sec = _db.Sections.Where(r =&gt; r.SectionId == SectionId).FirstOrDefault();
          char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
          List&lt;string&gt; l = new List&lt;string&gt;();
          l = sec.Tags.Split(delimiterChars).ToList();
  
          structure s = new structure();
          s.ress = res;
          s.liste = l;
  
          return View(s);
  
      }
  
      public string Check ( string list, string s)
      {
          char[] delimiterChars = { ' ', ',', '.', ':', '\t' };
          List&lt;string&gt; l = new List&lt;string&gt;();
          List&lt;string&gt; liste = new List&lt;string&gt;();
          l = s.Split(delimiterChars).ToList();
          liste = list.Split(delimiterChars).ToList();
          foreach (string item in l)
          {
              if (!liste.Contains(item))
                  liste.Add(item);
          }
          return  (string.Join(" ", liste.ToArray()));
      }
  
      [Authorize]
      [HttpPost]
      [InitializeSimpleMembership]
      public ActionResult AjouterRessource(Ressource res, int SectionId, string tag)
      {
          if (ModelState.IsValid)
          {
  
              res.SectionId = SectionId;
              var model = _db.Sections.Where(c =&gt; c.SectionId == SectionId).FirstOrDefault();
              res.Tags = tag;
              model.Tags = Check(model.Tags, tag);
              _db.Entry(model).State = EntityState.Modified;
              _db.Entry(res).State = EntityState.Added;
              _db.SaveChanges();
              return RedirectToAction("Section", new { SectionId = SectionId });
          }
          return View();
  
      }
  </code></pre>
  
  <p>I keep getting: Object reference not set to an instance of an object on the line:  <code>@Html.ValidationSummary(true)</code> in my view. Can you tell me how to fix it please? </p>
  
  <p>Thank you</p>