IIS7劫持了我的Coldfusion错误页面

Tyl*_*nin 8 iis coldfusion iis-7 http-status-code-404

在我的异常处理文件中,我将状态代码设置为404,然后为错误页面(想想失败鲸鱼)渲染n个HTML页面.

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

<html><head><title>Error</title></head><body><h1>There was an error yo!</h1></body></html>
Run Code Online (Sandbox Code Playgroud)

这显然过于简化,但只是为了确保一切都得到了证明.

我发现,从ASP.NET请求中,他们可以设置变量"Response.TrySkipIisCustomErrors = true",以防止IIS显示自己的错误页面.

Coldfusion中的某个人怎么做呢/我怎么能告诉IIS停止它认为它比我的诡计更好.

Kev*_*Kev 21

这可能有所帮助:

<configuration>
  <system.webServer>
    <httpErrors existingResponse="PassThrough" />
  </system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)

欲获得更多信息:

HTTP错误(IIS.NET)
IIS7自定义错误模块(IIS.NET)可以期待什么

如果这不起作用,那么您可以尝试编写.NET HttpModule以插入要设置的IIS请求/响应管道Response.TrySkipCustomErrors.不理想.

ASP.NET的worker请求对象调用一个名为的导出函数MgdSetStatusW.这里的问题是,除非Coldfusion公开此标志,否则您将无法直接在CF中设置该值.

使用.NET Reflector我看到ASP.NET使用以下方式设置响应状态:

[DllImport("webengine4.dll", CharSet=CharSet.Unicode)]
internal static extern int MgdSetStatusW(IntPtr pRequestContext, 
    int dwStatusCode, int dwSubStatusCode, string pszReason, 
    string pszErrorDescription, bool fTrySkipCustomErrors);
Run Code Online (Sandbox Code Playgroud)