The HttpResponseMessage has a constructor that takes in a value of the HttpStatusCode enum. Most of the http status codes you need are available in that enum.

But what if you need to set the status code to a value that hasn’t been defined in the enum? You might have a Web Api that has a rate limit (throttling). In that case you may want to return 429 Too Many Request.