title: ASP.NET MVC5 : How do I pass data to a view?
body: <p>I have a problem with this action:</p>
  
  <p>"activateOffreLocation" checks the value of "Publication_Statut" and change it ( if it equals "Activée", the action change it to "Désactivée" and vice versa</p>
  
  <p>i don't get any error ! it switch simply to the " listOffreLocation" view after asking the confirmation !</p>
  
  <p>i tried to follow the execution with break Points, it turned that in my Post Action the "offreLocation" is null, while the ID is not, it contains the right value of the selected ITEM in the first view.  </p>
  
  <pre><code>         // GET: /OffreLocation/Activate
      public ActionResult ActivateOffreLocation(int id)
      {
          return View(db.PublicationSet.Find(id));
      }
  
  
      // POST: /OffreLocation/Activate
      [HttpPost]
      public ActionResult ActivateOffreLocation(int id, OffreLocation offreLocation)
      {
          try {
              var statut = offreLocation.Publication_Statut;
  
                 if(String.Equals(statut,"Activée"))
                          {
                              offreLocation.Publication_Statut = "Désactivée";
                              db.SaveChanges();
                              return View();
                          }
              else 
                          {
                              offreLocation.Publication_Statut = "Activée";
                              db.SaveChanges();              
                              return RedirectToAction("ListOffreLocation"); 
                          }              
               } 
          catch (Exception exp)
          {
              Console.WriteLine("IOException source: {0}", exp.Source);
              return RedirectToAction("Error"); 
          }                      
      }
  </code></pre>
  
  <p>in my view " listOffreLocation " i just defined the link to the "activateOffreLocation" view:</p>
  
  <pre><code>@Html.ActionLink("Désactiver", "ActivateOffreLocation", new { id = item.Publication_ID }) | 
  </code></pre>
  
  <p>"ActivateOffreLocation" View:</p>
  
  <pre><code>&lt;fieldset style="border:dashed; margin-top:80px"&gt;
  &lt;h3 style="text-align: center; margin-left:80px; margin-top:80px"&gt;  Voullez vous vraiment désactiver cette offre de location?   
  &lt;/h3&gt;
  &lt;h4 style="text-align:center"&gt;  Num:    @Html.EditorFor(model =&gt; model.Publication_ID) &lt;/h4&gt;
  &lt;h4 style="text-align:center"&gt;  Statut    @Html.EditorFor(model =&gt; model.Publication_Statut) &lt;/h4&gt;
      &lt;div style="margin-bottom:80px"&gt;
  
          &lt;hr /&gt;
  
  
          @using (Html.BeginForm())
          {
              @Html.AntiForgeryToken()
              @Html.HiddenFor(model =&gt;model.Publication_ID) 
              &lt;div class="form-actions no-color" style="text-align:center"&gt;
                  @Html.HiddenFor(model =&gt; model.Publication_ID)
                  &lt;input type="submit" value="Désactiver" class="btn btn-default" /&gt; |
                  @Html.ActionLink("Retour à la  Liste", "ListOffreLocation")
  
              &lt;/div&gt;
          }
      &lt;/div&gt;
   &lt;/fieldset&gt;
  </code></pre>