title: Random redirect to /Undefined
body: <p>I'm working on an internal MVC site.</p>
  
  <p><strong>Issue:</strong></p>
  
  <p>Suddenly the site has started redirecting to <code>localhost/undefined</code> in select browsers (Chrome, Opera, and Safari) before/after a delete POST. This does not happen in Firefox or IE.</p>
  
  <p><strong>Steps Taken:</strong></p>
  
  <p>I've stepped through the following javascript code numerous times on Chrome(not working) and IE(working). There appear to be no difference other than Chrome finishing with a random redirect that is not called upon in the code.</p>
  
  <p><strong>Jquery AJAX Call below:</strong></p>
  
  <pre><code>// Delete button clicked
  function deleteEntity(e) {
      e.preventDefault();
  
      var name = $(this).attr("name");
      var index = $(".deleteEntity[name=" + name + "]").index($(this));
      var entityId = ko.utils.unwrapObservable(viewModel.model.peek()[index].ID);
      var data = { EntityID: entityId };
  
      viewModel.model.remove(viewModel.model.peek()[index]);
  
      if (entityId &gt; 0) {
          $.ajax({
              url: "/" + name + "/Delete",
              type: "POST",
              data: data,
              dataType: 'json',
              async: true,
              success: function (data, textStatus, xhr) {
                  alert(data);
              },
              error: function (xhr, textStatus, errorThrown) {
                  // Decide later.
              }
          });
      }
  }
  
  $(document).on("click", ".deleteEntity", deleteEntity);
  </code></pre>
  
  <p><strong>Debugging Steps</strong>:</p>
  
  <p>Starting at a break at the line of the ajax call. -> <code>if (entityId &gt; 0) {</code>.</p>
  
  <ul>
  <li>If I hit F8 here to pass through to my breaks at the <code>success</code> and <code>error</code> functions, it ends up not hitting either of the breakpoints and redirecting to <code>localhost/undefined</code> without contacting the server.</li>
  <li>If I hit F10 to step through it will stop at my breakpoint on the server in the delete action. From there I hit F5 in visual studio and it deletes the selected expected entity returning me to my breakpoint in the broswer. If I hit F8 from here it will hit success and popup the alert box with success. </li>
  <li>If I hit F8 in the broswer before hitting F5 in visual studio however it will instantly redirect to <code>localhost/undefined</code>.</li>
  </ul>
  
  <p><strong>Question:</strong> Does anyone know the origin of this problem? I've googled around and found a very similar issue relating to plugins so I tried disabling all of the (a whole 2) and it did not change anything.</p>
  
  <p>p.s. if any other code snippets will be helpful just comment and I'll add them. I've checked my actions over at least 20 times. The <code>Delete</code> is an <code>[HttpPost]</code> but so is my <code>Update</code> and it's working fine in the same exact fashion.</p>