title: Using ASP.NET WebAPI to return Boolean to be consumed by an Ajax GET request
body: <p>I have built a WebAPI (using version 2) that returns <code>HttpResponseMessage</code>.  I make <code>AJAX</code> requests to these WebAPI methods, and the WebAPI returns a <code>JSON</code> response.  This is all fine and dandy, but now what I need is a way to make an <code>AJAX</code> GET request to a WebAPI method that simply returns a Boolean.  Here's an example of a <code>GET</code> request I'm using to get <code>JSON</code>:</p>
  
  <pre><code>$.ajax({
      url: 'http://server/site/api/BulletinBoard/GetUserMessageHistory?userId=' + userId + '&amp;messageId=' + messageId,
      type: 'GET',
      dataType: 'json',
      crossDomain: true,
      success: function (data) {
            DoSomething();                    
      },
      error: function (x, y, z) {
            alert(x + '\n' + y + '\n' + z);
      }
  });
  </code></pre>
  
  <p>What I hope to accomplish is something like (this is pseudo-code):</p>
  
  <pre><code>    var hasMessageBeenDisplayed = 
          $.ajax({
                url: 'http://server/site/api/BulletinBoard/GetUserMessageHistory?userId=' + userId + '&amp;messageId=' + messageId,
                type: 'GET',
                dataType: 'json',
                crossDomain: true,
                success: function (data) {
                     DoSomething();                    
                },
                error: function (x, y, z) {
                     alert(x + '\n' + y + '\n' + z);
                }
         });
  </code></pre>
  
  <p>Where <code>hasMessageBeenDisplayed</code> would be either <code>true</code> or <code>false</code> returned by my WebAPI method.  Here's an example of my WebAPI method:</p>
  
  <pre><code>[HttpGet]
  public HttpResponseMessage GetUserMessageHistory(string userId, int messageId)
  {
      var userMessageHistory = (from i in db.UserMessageHistories
                                where i.UserId == userId &amp;&amp;
                                i.MessageId == messageId
                                select new
                                {
                                    UserId = i.UserId,
                                    MessageId = i.MessageId,
                                    LastSeen = i.LastSeen,
                                }).ToList();
  
      HttpResponseMessage response = Request.CreateResponse(HttpStatusCode.OK, userMessageHistory);
      return response;
  }
  </code></pre>
  
  <p>To be able to make an <code>AJAX</code> request that expects <code>true</code> or <code>false</code>, would I still return <code>HttpResponseMessage</code> from my WebAPI method?  How can I make an <code>AJAX</code> GET request whose method it's calling can return <code>true</code> or <code>false</code>?</p>