title: Setting Response.Status Generates "HTTP Status String is Not Valid" Exception
body: <p>I'm writing an HTTP handler in ASP.NET 4.0 and IIS7 and I need to generate a file-not-found condition.</p>
  
  <p>I copied the following code from Mathew McDonald's new book, Pro ASP.Net 4 in C# 2010. (The response variable is an instance of the current HttpResponse.)</p>
  
  <pre><code>response.Status = "File not found";
  response.StatusCode = 404;
  </code></pre>
  
  <p>However, I found that the first line generates the run-time error <code>HTTP status string is not valid.</code></p>
  
  <p>If, instead of the lines above, I use the following:</p>
  
  <pre><code>response.Status = "404 Not found";
  </code></pre>
  
  <p>Then everything seems to work fine. In fact, I even see that response.StatusCode is set to 404 automatically.</p>
  
  <p>My problem is that I don't want this to fail on the production server. So I'd feel much better if I could understand the "correct" way to accomplish this. Why did the first approach work for Mathew McDonald but not for me? And is the second approach always going to be reliable?</p>
  
  <p>Can anyone offer any tips?</p>