title: Return HTTP status code using REST API
body: <p>How do we return a HTTP status code with the object returned in REST API using VB.NET Framework 4.0? </p>
  
  <p>I have Googled this and found some solutions like throwing the error before returning the object as below:</p>
  
  <pre><code>Public Function InfoAndTerms(ByVal Lang As String) As Information() Implements IService.InfoAndTerms
  
  Dim result() As Information    
  Try
      ' Do something and fill result
  Catch ex As Exception
      Throw New System.Web.HttpException(500, "Error - InfoAndTerms")
  Finally  
          InfoAndTerms = result
  End Try   
  
  End Function
  </code></pre>
  
  <p>But in my case this function is always returning status 400 instead of 500 and I don't know why.</p>
  
  <p>How do I fix this problem? Is there any other way to do that?</p>