title: ASP.NET MVC 4 call a controller method from another controller
body: <p>I am stuck on this issue. I have two controllers, UsersController and HomeController I am trying to call a controller method from UsersController from another controller (HomeController) by doing this:</p>
  
  <pre><code>UsersController usersController = new UsersController();
  </code></pre>
  
  <p>but I get this error: Generate constructor stub in 'CTHRC.Roti.Web.UI.Controllers.UsersController'</p>
  
  <p>I do not understand this error.</p>
  
  <p>Here is my UsersController:</p>
  
  <pre><code>using System;
  using System.IO;
  using System.Text;
  using System.Collections.Generic;
  using System.Linq;
  using System.Net;
  using System.Net.Http;
  using System.Net.Http.Headers;
  using System.Web;
  using System.Web.Http;
  using CTHRC.Roti.Domain.Api.Services;
  using CTHRC.Roti.Domain.Model;
  
  namespace CTHRC.Roti.Web.UI.Controllers
  {
      public class UsersController : ApiController
      {
           protected readonly UsersService UsersService;
  
          public UsersController(UsersService usersService)
          {
              UsersService = usersService;
          }
  
          [HttpGet]
          public dynamic Get(int UserId)
          {
              return UsersService.Get(UserId);
          }
      }
  }
  </code></pre>
  
  <p>Here is my HomeController:</p>
  
  <pre><code>using System;
  using System.Collections.Generic;
  using System.Linq;
  using System.Web;
  using System.Web.Mvc;
  using WebMatrix.WebData;
  
  namespace CTHRC.Roti.Web.UI.Controllers
  {
      public class HomeController : Controller
      {
          //
          // GET: /Default/
  
          public ActionResult Index()
          {
              if (!WebSecurity.IsAuthenticated)
              {
                  Response.Redirect("~/account/login");
              }
              UsersController userController = new UsersController();
              return View();
  
          }
  
      }
  }
  </code></pre>
  
  <p>What do I have to do to fix this? Any help would be appreciated. Thanks. The reason I am trying to do this is because I want the data from the controller method.</p>