title: How Do You Call a Controller Action That Will Return to The Calling Controller But Also Can Have A RedirectToAction
body: <p>I have a controller in my .Net Core 3.1 app that calls another controller action. Before I added a <code>RedirectToAction</code> in the called controller everything worked fine. I now want that controller to redirect to an error page if appropriate, otherwise back to where it was called in the original controller.</p>
  <p>Here is the code in my controller:</p>
  <pre class="lang-cs prettyprint-override"><code>public ActionResult Edit(IFormCollection collection, string saveClose)
  {
      //do stuff
      LoadArrayDataForDB(Id, collection[&quot;names&quot;].ToString(), collection[&quot;places&quot;].ToString(), collection[&quot;countries&quot;].ToString());
      //do more stuff
      
      return View(IVM);
  }
  
  //This was the Original LoadArrayDataForDB action
  public void LoadArrayDataForDB(string id, string names, string places, string countries)
  {
      //add error checking
      _adoSqlService.DeleteAffectedNames(id);
      _adoSqlService.DeleteSelectedPlaces(id);
      _adoSqlService.DeleteCountries(id);
  }
  
  //This is how I need to change the LoadArrayDataForDB action
  public void LoadArrayDataForDB(string id, string names, string places, string countries)
  { 
      //add error checking
      string done = _adoSqlService.DeleteAffectedNames(id);
      if (done != &quot;Successful&quot;)
      {
          return RedirectToAction(&quot;Error&quot;, &quot;Home&quot;, new { errordescription = &quot;Unable to delete names&quot; });
      }
  
      done = _adoSqlService.DeleteAffectedPlaces(id);
      if (done != &quot;Successful&quot;)
      {
          return RedirectToAction(&quot;Error&quot;, &quot;Home&quot;, new { errordescription = &quot;Unable to delete places&quot; });
      }       
  
      done = _adoSqlService.DeleteAffectedCountries(id);
      if (done != &quot;Successful&quot;)
      {
          return RedirectToAction(&quot;Error&quot;, &quot;Home&quot;, new { errordescription = &quot;Unable to delete countries&quot; });
      }       
      //etc....
      //Just return back to next step in the Edit action
  }
  </code></pre>
  <p>How can I do what I need to do?</p>