Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

IIS7 Hijacks My Coldfusion Error Page

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.

like image 576
Tyler Clendenin Avatar asked Oct 14 '10 19:10

Tyler Clendenin


1 Answers

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);
like image 138
Kev Avatar answered Nov 01 '22 09:11

Kev