Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Getting IIS 6 to return specific HTTP status code programatically with Classic ASP

I searched and didn't find a suitable answer.

I have a custom 404 page that, when triggered:

  1. parses the requested URL for a specific string
  2. checks a database for this value
  3. inserts specific HTTP header(s) based on results returned from db

Depending on the condition, I will send this to the browser:

Response.AddHeader "Location", a_dynamic_url
Response.Status = "301 Moved"

When the specific string is found in my database, the client browser behaves as desired by loading the dynamic URL I've set in the location header.

Here's my issue...

When the specific string is NOT FOUND in my database, I'm unable to set status to "404 Not Found" and display custom HTML in the browser.

I can do one or the other, but not both at the same time. It's either the 404 status, or custom HTML (with status of 200).

In contrast, if you use HTTP Fox in Firefox to see the request/response headers, then navigate to an unknown bit.ly URL (like: "bit.ly/asdfasdf") the status returned is 404 and the HTML is custom.

Any ideas on how I can rig IIS 6 to do the same thing with Classic ASP?

like image 216
10 revs, 4 users 79% Avatar asked Dec 06 '25 19:12

10 revs, 4 users 79%


1 Answers

Are you aware of the "IE Friendly Errors" and the 512 bytes of content that your HTML needs to have to make sure that your HTML (instead of IE's friendly status message) shows up to your users?

http://weblogs.asp.net/scottgu/archive/2006/04/09/442332.aspx

like image 52
Eduardo Molteni Avatar answered Dec 08 '25 16:12

Eduardo Molteni