title: ASP.NET MVC: "add comment" underneath "details" of "ticket"
body: <p>I'm fairly new to ASP.NET MVC. The idea is very straightforward, but I can't seem to make it work.</p>
  
  <p>I have a "ticket", which can be viewed under /Tickets/Details/[id]. Underneath this ticket is a list of comments and a "add comment" section. In the beginning I tested it all separately and manually wrote the TicketID. Now I need to save the current ticket's id and the whole ticket in this comment for later use. After the comment is successfully saved the page (of the ticket) should be refreshed.</p>
  
  <p>Based on previous experience in ASP I tried this underneath my ticket details</p>
  
  <pre><code>&lt;div class="panel panel-info"&gt;
  &lt;div class="panel-heading"&gt;Comments&lt;/div&gt;
  &lt;div class="panel-body"&gt;
      @{
          Html.RenderAction("create", "TicketComments");
      }
  &lt;/div&gt;
  </code></pre>
  
  <p></p>
  
  <p>I tried the following thing in my TicketCommentsController.cs:</p>
  
  <pre><code>    public ActionResult Create([Bind(Include = "ID, body")] TicketComment ticketComment)
      {
          Ticket ticket = db.Tickets.Find(ticketComment.ID);
  
          if (ModelState.IsValid)
          {
              ticketComment.UserID = User.Identity.GetUserId();
              ticketComment.AanmaakDateTime = DateTime.Now.ToLocalTime();
              ticketComment.UpdateDateTime = DateTime.Now.ToLocalTime();
              ticketComment.ParentTicketId = ticket.ID;
              ticketComment.ParentTicket = ticket;
              db.TicketComments.Add(ticketComment);
              db.SaveChanges();
  
              return View(ticket);
          }
  
          return View(ticket);
      }
  </code></pre>
  
  <p>but on the return it gives me an excpetion:</p>
  
  <blockquote>
    <p>"The model item passed into the dictionary is of type 'System.Data.Entity.DynamicProxies.Ticket_5309A05301E0FE6AD5614FE3ED9E54D6FAB46DFEAFB2A38B4341FACD04441DF5', but this dictionary requires a model item of type 'Cronos.Models.TicketComment'."</p>
  </blockquote>
  
  <p>I'm confused on what to do next. One thing I read was merge the TicketCommentsController in TicketsController, but this feels messy.</p>
  
  <p>Can anyone help?</p>