Coldfusion 错误和 IIS7.5 错误页面 [英] Coldfusion Error and IIS7.5 Error Pages

查看:15
本文介绍了Coldfusion 错误和 IIS7.5 错误页面的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

为了让 ColdFusion 显示其错误而不仅仅是服务器错误(代码 500),我根据本网站的一些发现添加到 web.config.

In order to allows ColdFusion showing its errors instead of just server error (code 500), I have added to web.config according to some findings in this site.

问题看起来已经解决了,但是...

The problem looks resolved but...

当我访问 IIS 中不存在的目录时,它返回了一个没有任何状态代码的空白"页面.如果我将其从 passthrough 设置回 auto,IIS 会再次显示错误页面,并且不再显示 ColdFusion 错误.

When I visit a non-existed directory in the IIS, it returned a "blank" page without any status code. If I set it from passthrough back to auto, the IIS takes the error page again and no more ColdFusion errors showed.

有人有解决办法吗?我做了一些研究并怀疑" JWildcardhandler 可能是问题所在,但我找不到解决方案.

Anyone has a solution? I did some research and "suspect" that the JWildcardhandler maybe the problem, but I couldn't find a solution to this.

非常感谢!

推荐答案

如果有人想知道这个人的网络配置可能如下所示:

In case anyone is wondering this person's web config probably looks like this:

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <httpErrors existingResponse="PassThrough" />
        ...
    </system.webServer>
</configuration>

在早期版本的 IIS 中,如果您的自定义脚本返回错误代码,IIS 会忽略它并让它通过.但是您也可以将其设置为使用自定义脚本处理错误状态.

In earlier version of IIS, if your custom script returned an error code, IIS ignored it and let it through. But you could also set it up to handle error status with custom scripts.

在我的旧服务器上,如果给定的 URL 是 404,则 IIS 设置为执行/404.cfm,显示错误页面并且使用 < 返回 404 状态代码;cfheader>.

On my old server, if a given URL was a 404, IIS was set up to execut /404.cfm, which displayed an error page and returned a 404 status code using <cfheader>.

但是,现在如果该脚本返回 404 状态码,最终结果是 IIS 返回服务器错误,而不是返回带有 404 状态码的响应.

However, now if that script returns a 404 status code, the end result is IIS returns a server error rather than return the response with the 404 status code.

避免这种情况的唯一方法是使用 existingResponse="PassThrough",然后使用在 CFAdmin 中设置的站点范围的找不到模板"模板.

The only way to avoid that is by using existingResponse="PassThrough" and then using a site-wide "Template Not Found" template, set in CFAdmin.

这是有趣的部分.我已将 index.cfm 设置为默认索引,并且为我的站点设置了 only 默认索引.

Here's the interesting part. I have index.cfm set up as the default index, and the only default index, for my site.

如果我转到 /about/,并且 /about/index.cfm 存在,那么它会呈现页面,就好像我向它询问了 /about/index.cfm.如果我去 /about/index.cfm 并且 /about/index.cfm not 存在,它会执行站点范围的 404模板.

If I go to /about/, and /about/index.cfm exists, then it renders the page, as if I had asked it for /about/index.cfm. And if I go to /about/index.cfm and /about/index.cfm does not exist, it executes the site-wide 404 template.

但是如果我去 /about/ 并且 /about/ 不作为 URL 存在,它确实尝试加载 /about/index.cfm 并因此触发站点范围的 404 模板.相反,它会呈现一个空白页面!

But if I go to /about/ and /about/ does not exist as an URL, it does not attempt to load /about/index.cfm and thus trigger the site-wide 404 template. Instead, it renders a blank page!

据我所知,这个问题没有可行的解决方案.看起来只有用 .Net 编写的人才能解决这个问题,因为他们可以在他们生成的响应中放置一个标志,字面上告诉 IIS忽略状态代码".我认为 Microsoft 根本对支持替代 Web 应用程序不感兴趣.

As far as I can tell, there is no workable solution to this problem. It looks like only people writing in .Net can resolve this issue, as they can put a flag in the Response that they generate that literally tells IIS "Ignore the status code". I think that Microsoft simply isn't interested in supporting alternate web application.

基本上,这是解决方案:去掉 existingResponse="PassThrough" 并返回错误的状态码.

Basically, this is the solution: get rid of existingResponse="PassThrough" and return the wrong status codes.

其他任何事情都将难以实施.请注意,如果您正在制作 RESTful 应用程序或 API,这将不起作用.在这种情况下,您必须为此创建一个虚拟目录,您可以为其分配一个自定义 web.config 文件,确实使用 existingResponse="PassThrough".但是,如果您需要能够允许自定义错误处理和自定义 404 处理,那您就完蛋了.

Anything else is going to be too hard to implement. Note that this does not work if you are making a RESTful app or API. In which case, you must create a virtual directory just for that, for which you can assign a custom web.config file which does use existingResponse="PassThrough". But if you need to be able to allow custom error handling and custom 404 handling, you are effectively screwed.

好消息是,除了 API 和 Ajax 之外,唯一一次有人会关心实际状态代码是在他们查看您的标头时,在这种情况下他们会看到您正在运行IIS,只是为你感到难过.

The good news is, apart from API and Ajax, the only other time someone will care about what the status code actually is will be when they're looking at your headers anyway, in which case they will see you're running IIS and just feel sorry for you.

这篇关于Coldfusion 错误和 IIS7.5 错误页面的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆