title: "Controller, Action, Model" not all code paths return a value
body: <p>I am really confused by this error &quot;not all code paths return a value&quot; on my action PostResponse. I have stared at my model, controller and view for hours and I think I have all paths covered. Of course the project won't build, so I can't debug further.</p>
  <p>My action</p>
  <pre><code>    // POST: /Questions/ViewQuestion/5
      [HttpPost]
      [ValidateAntiForgeryToken]
      public ActionResult PostResponse([Bind(Include = &quot;UserId,QuestionID,Answer,Source,Status,DateStamp&quot;)] Response response)
      {
          if (ModelState.IsValid)
          {
              db.Responses.Add(response);
              db.SaveChanges();
          }
      }
  </code></pre>
  <p>My view</p>
  <pre><code>@model Template.Models.Question
  @using Microsoft.AspNet.Identity
  @{
     ViewBag.Title = &quot;View question&quot;;
      var qtype = Model.QuestionTypeId;
      ViewBag.Number = Model.Id - 7;
      
  }
  @using (Html.BeginForm(&quot;Question&quot;, &quot;ViewQuestion&quot;, FormMethod.Post, new { @class = &quot;form-horizontal&quot;, role = &quot;form&quot; }))
  &lt;div&gt;
      &lt;h4&gt;Question #@ViewBag.Number&lt;/h4&gt;
      &lt;hr /&gt;
      &lt;h1&gt; @Model.Question1&lt;/h1&gt;
  &lt;/div&gt;
  
  &lt;div class=&quot;form-group&quot;&gt;
      @switch (qtype)
      {
          case 1:
          // Textbox
              @Html.TextArea(&quot;Answer&quot;, new { @class = &quot;form-control&quot;, rows = &quot;4&quot;, col = &quot;5&quot; });
              break;
          case 2:
          //      Dropdown
          &lt;select class=&quot;form-control&quot; id=&quot;Answer&quot;&gt;
              @foreach (var item in Model.QuestionOptions.OrderBy(o =&gt; o.QuestionOptionRanking))
              {
                  &lt;option value=&quot;@item.QuestionOption1&quot;&gt;@item.QuestionOption1&lt;/option&gt;
  
              }
          &lt;/select&gt;
              break;
          case 3:
          //     Checkbox
          &lt;div class=&quot;checkbox&quot;&gt;
                      @foreach (var item in Model.QuestionOptions.OrderBy(o =&gt; o.QuestionOptionRanking))
  {
      &lt;input type=&quot;checkbox&quot; name=&quot;Answer&quot; value=&quot;@item.QuestionOption1&quot; /&gt;  @item.QuestionOption1 &lt;br /&gt;
                      }
          &lt;/div&gt;
          break;
  
          case 4:
          //      Radio buttons
          foreach (var item in Model.QuestionOptions.OrderBy(o =&gt; o.QuestionOptionRanking))
              {
                  &lt;div class=&quot;radio&quot;&gt;
                      &lt;label&gt;
                          &lt;input type=&quot;radio&quot; name=&quot;Answer&quot; value=&quot;@item.QuestionOption1&quot; /&gt;
                          @item.QuestionOption1
                      &lt;/label&gt;
                  &lt;/div&gt;
              }
  
              break;
      }
  
  &lt;/div&gt;
  @using Template.Models.Response
  @Html.HiddenFor(r =&gt; r.Responses, new { UserId = User.Identity.GetUserId(), Source = &quot;Web&quot;, Status = &quot;New&quot;, DateStamp = System.DateTime.Now })
  &lt;div class=&quot;form-group&quot;&gt;
      &lt;div class=&quot;col-md-offset-2 col-md-10&quot;&gt;
          &lt;input type=&quot;submit&quot; class=&quot;btn btn-default&quot; value=&quot;Answer&quot; /&gt;
      &lt;/div&gt;
  &lt;/div&gt;
  &lt;br /&gt;
  &lt;hr /&gt;
  &lt;p&gt;
  
      @Html.ActionLink(&quot;Previous&quot;, &quot;ViewQuestion&quot;, new { id = Model.Id - 1 }) |
      @Html.ActionLink(&quot;Next&quot;, &quot;ViewQuestion&quot;, new { id = Model.Id + 1 })
  &lt;/p&gt;
  </code></pre>
  <p>The page displays perfectly, but I can't test the post action as I cannot build with the current error.</p>