title: Losing data from viewbag/tempdata after multiple post
body: <p>I've got problem with passing value. I am beginner in MVC, I read about <code>ViewBag</code>, <code>TempData</code> and I know it shouldn't work but I don't know how to make it work otherway. My problem:</p>
  
  <p>Got 2 models : <code>Animal</code> and <code>Visit</code></p>
  
  <p>in my AnimalView I got list of all animals and I got this ActionLink:</p>
  
  <pre><code>@Html.ActionLink("Add Visit", "Create", "Visit", new { id = item.AnimalID }, null) 
  </code></pre>
  
  <p>it goes to Create GET method with id passed, I get a view to create visit I can submit it and everything is fine but..</p>
  
  <p>for example if I don't set time for visit, model will not update and when method goes back to <code>Create</code> <code>Visit</code> View I don't have <code>AnimalID</code> already... can some1 tell me how to keep this value when post fails?</p>
  
  <p>public ActionResult Create(int id)
          {
              Animal animal = db.Animals.Find(id);
              if (animal == null)
              {
                  return HttpNotFound();
              }</p>
  
  <pre><code>       TempData["AnimalID"] = id;
          return View();
  
      }
  
      [HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult Create([Bind(Include = "VisitID,AnimalID,DoctorID,VisitDate,VisitHour,Price,Recognition,Medicines,VisitDescription")] Visit visit)
      {
  
  
  
          if (ModelState.IsValid)
          {
              visit.DoctorID = (int)Session["Doctors"];
  
              db.Visits.Add(visit);
              db.SaveChanges();
              return RedirectToAction("Index");
          }
  
          return View(visit);
      }
  </code></pre>