views:

55

answers:

1

In my exception handling file, I set a statuscode to 404 and then render n HTML page, for the error page (think fail-whale).

<cfheader statuscode="404" statustext="Application Exception">

<html><head><title>Error</title></head><body><h1>There was an error yo!</h1></body></html>

This is obviously over simplified, but just to make sure everything was demonstrated.

What I have found is that from a ASP.NET request, they can set a variable "Response.TrySkipIisCustomErrors=true" to keep IIS from showing its own error page.

How can someone in Coldfusion do it / how can I just tell IIS to stop its thinks it knows better than me shenanigans.

+3  A: 

This might help:

<configuration>
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
</configuration>

For more information:

HTTP Errors (IIS.NET)
What to expect from IIS7 custom error module (IIS.NET)

If that doesn't work then you might try writing a .NET HttpModule to plug into the IIS request/response pipeline to set Response.TrySkipCustomErrors. Not ideal.

ASP.NET's worker request object calls an exported function called MgdSetStatusW. The problem here is that unless Coldfusion exposes this flag then you won't be able to set the value directly in CF.

Poking around with .NET Reflector I seen ASP.NET setting the response status using:

[DllImport("webengine4.dll", CharSet=CharSet.Unicode)]
internal static extern int MgdSetStatusW(IntPtr pRequestContext, 
    int dwStatusCode, int dwSubStatusCode, string pszReason, 
    string pszErrorDescription, bool fTrySkipCustomErrors);
Kev
The web.config method kind of worked, but it still prepends a ridiculous "The page cannot be displayed because an internal server error has occurred." block of text before it displays my template. I don't know that I will write anything for .NET as that would be way too stupid to need to do. This solution needs to be modular so that if the site is copied to any server, whether it be Apache/IIS6/IIS7, everything just works.
Tyler Clendenin
@Tyler - probably something to raise with Adobe, painful though that process may be.
Kev
Wait, nevermind, I had that wrong, i was using errorMode instead of existingResponse. It works great now, thanks.
Tyler Clendenin
@tyler - .....yay!
Kev