title: c# WebApi provider IHttpActionResult in Class Library
body: <p>So I have created a provider which will handle all my code.
  Originally it looked like this:</p>
  
  <pre><code>public class AnswerProvider : ApiController
  {
  
      private readonly IUnitOfWork _unitOfWork;
      private readonly AnswerService _answerService;
  
      private QuestionService _questionService;
      public QuestionService QuestionService =&gt; _questionService ?? (_questionService = new QuestionService(this._unitOfWork));
  
      public AnswerProvider(IUnitOfWork unitOfWork)
      {
          this._unitOfWork = unitOfWork;
          this._answerService = new AnswerService(unitOfWork);
      }
  
      public async Task&lt;IHttpActionResult&gt; CreateAsync(AnswerRequestModel model)
      {
          try
          {
  
              // Validate our answer count
              await ValidateAnswerCountAsync(model.QuestionId);
  
              // Create our model
              var answer = ModelFactory.Create(model);
  
              // Add our images to our answer
              answer.Images = model.Images;
  
              // Save our model
              this._answerService.Create(answer);
  
              // Save the database changes
              await this._unitOfWork.SaveChangesAsync();
  
              // Return our updated model
              return Ok(ModelFactory.Create(answer));
  
              // If there is an error
          }
          catch (Exception ex)
          {
  
              // Return our error
              return BadRequest(ex.Message.ToString());
          }
      }
  
      /// &lt;summary&gt;
      /// Validates the answers based on the question type
      /// &lt;/summary&gt;
      /// &lt;param name="id"&gt;The id of the question&lt;/param&gt;
      /// &lt;returns&gt;&lt;/returns&gt;
      private async Task ValidateAnswerCountAsync(int id)
      {
  
          // Get our question
          var question = await this.QuestionService.GetAsync(id, "Answers");
  
          // If we have 3 answers or more
          if (question.Answers.Count &gt;= 3 &amp;&amp; question.Type == QuestionType.Boolean)
          {
  
              // Throw an error
              throw new InvalidOperationException("A Boolean question can only have 3 answers");
          }
      }
  }
  </code></pre>
  
  <p>I inherited ApiController because I want to gain access to the <strong>Ok</strong>, <strong>BadRequest</strong> and other such methods, that is the only reason.
  When I try to run that code, even though it compiles I get this error:</p>
  
  <blockquote>
    <p>HttpControllerContext.Configuration must not be null</p>
  </blockquote>
  
  <p>I assume that is because I am trying to inherit the <strong>ApiController</strong> and I shouldn't be doing that.
  Is there another way I can get access the the <strong>Ok</strong> and other similar methods without inheriting the <strong>ApiController</strong>. 
  Please bare in mind that I will have more than one provider. </p>