title: Problems trying to return the view with an API controller
body: <p>I'm implementing a REST Web API. I'm using the examples from Adam Freeman's Pro ASP.NET MVC5 as a starting point but adapting it into the Web API way of doing it.</p>
  
  <p>The below is my code:</p>
  
  <pre><code>public class AdminController : ApiController
  {        
      private IUserRepository _repository;
      public AdminController(IUserRepository repository) 
      {
          _repository = repository; 
      }
  
      public ActionResult Index()
      {
          return View(_repository.Users);
      }
  }
  </code></pre>
  
  <p>In the book, <code>AdminController</code> implemented <code>Controller</code> not <code>ApiController</code>, but if I do that then I get errors about there being no parameterless constructor. I need the constructor to take parameters so that I can inject the dependencies. So that's why I changed to <code>ApiController</code> but now it won't recognise <code>View</code>.</p>
  
  <p>What do I need to use instead of <code>View</code> for an <code>ApiController</code>? </p>
  
  <p>I did find <a href="https://stackoverflow.com/questions/22146823/asp-net-mvc-using-web-api-to-return-a-razor-view">this question</a> but the answer was basically "you don't need to use an ApiController here, just use Controller" so that didn't help me.</p>