title: How do I redirect within a ViewResult or ActionResult function?
body: <p>Say I have:</p>
  
  <pre><code>public ViewResult List() 
  {
      IEnumerable&lt;IModel&gt; myList = repository.GetMyList();
      if(1 == myList.Count())
      {
          RedirectToAction("Edit", new { id = myList.Single().id });
      }
  
      return View(myList);
  }
  </code></pre>
  
  <p>Inside this function, I check if there is only one item in the list, if there is I'd like to redirect straight to the controller that handles the list item, otherwise I want to display the List View.</p>
  
  <p>How do I do this? Simply adding a <code>RedirectToAction</code> doesn't work - the call is hit but VS just steps over it and tries to return the View at the bottom. </p>