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:
- parses the requested URL for a specific string
- checks a database for this value
- 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 开发者_StackOverflow社区same thing with Classic ASP?
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
精彩评论