Setting Response.Status Generates “HTTP Status String is Not Valid” Exception

That’s because the Status property is the complete status line sent to the client, not only the message.

You can either write:

response.Status = "404 File not found";

Or, preferably:

response.StatusCode = 404;
response.StatusDescription = "File not found";

Note that, according to its documentation, HttpResponse.Status is deprecated in favor of HttpResponse.StatusDescription.

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)