I am trying to find out why there is a discrepancy between error codes shown in IIS server logs and the actual error returned to browser. Here is some background info:
- IIS 7
- Rewrite module in use, set up to rewrite all requests to custom rewrite/redirect module
- Custom rewrite module handles fine URLs that are set up in custom rewrite or redirect tables (performing either redirect or transferring the request to a correct script)
- However, if the URL is NOT set up in rewrite/redirect tables, then it executes Server.TransferRequest to the originally requested URL
- If originally requested URL is for existing scripts, then the page renders fine.
However, if the request comes for non-existing script/non-existing URL (which is neither redirected nor rewritten), then I can see that Server.TransferRequest results in 404 in IIS logs, but browser receives HTTP 500
So the question is why does Server.TrasnferRequest(requestURL,true); correctly logs 404 in IIS server logs, but returns HTTP 500 to browser?
For example, if we have the following in custom rewrite/redirect script:
requestURL = "/non-existant-url"
Server.TransferRequest(requestURL,true);
Is there some error response that will be returned that needs to be checked after that call and then send programatically 404 based on the response? Or anything else?
Many thanks