7

We currently have a classic asp 404 error page. By default, it's returning a status code 200 error, and we want it to return a 404 error code. How do you set the status code for a page in classic asp (vbscript)?

casperOne
  • 73,706
  • 19
  • 184
  • 253
gleasonomicon
  • 1,069
  • 5
  • 13
  • 24
  • 1
    possible duplicate of [Asp Classic return specific http status code](http://stackoverflow.com/questions/1456110/asp-classic-return-specific-http-status-code) – Justin Niessner Apr 26 '11 at 20:10
  • Possible duplicate of [Asp Classic return specific http status code](https://stackoverflow.com/questions/1456110/asp-classic-return-specific-http-status-code) – ADyson Jul 25 '19 at 13:33

2 Answers2

11

Use the Response object:

Response.Status = "404 Not found"
driis
  • 161,458
  • 45
  • 265
  • 341
  • 1
    @gleasonomicon--And make sure it's either at the top of the page, or response buffering is set to true. – dawebber Apr 26 '11 at 20:17
1

Technically, 200 is a status code OK, not an error, but nevertheless, the basic idea is that you need to tell the Response stream to return 404 (Not found) for the status code. Here's one way to do that.

dawebber
  • 3,503
  • 1
  • 16
  • 16