Windows Azure网站正在覆盖我的node.js应用程序中的404和500错误页面

我正在使用Windows Azure网站托pipenode.js应用程序。 到目前为止,除了我的自定义错误,一切都很好。 在我的节点应用程序中,我有一个error handling程序,可以在我的本地机器上呈现自定义404和自定义500错误页面。 但是,只要我发布到azure它将覆盖响应时,我将statusCode设置为除200以外的任何内容。

如果我没有将500或404状态码传递给响应,则不会发生这种情况,但是我希望状态码能够传递给浏览器。 本地我得到我的自定义错误页面就好了:

但是,在azure色的网站上,它只返回一行文字:

页面无法显示,因为发生了内部服务器错误。

我试图创build自己的web.config来覆盖默认的自定义错误禁用,但似乎没有任何效果。 这是我的web.config:

<?xml version="1.0" encoding="utf-8"?> <configuration> <system.web> <customErrors mode="off" /> </system.web> <system.webServer> <handlers> <add name="iisnode" path="app.js" verb="*" modules="iisnode"/> </handlers> <rewrite> <rules> <rule name="StaticContent"> <action type="Rewrite" url="public{REQUEST_URI}"/> </rule> <rule name="DynamicContent"> <conditions> <add input="{REQUEST_FILENAME}" matchType="IsFile" negate="True"/> </conditions> <action type="Rewrite" url="app.js"/> </rule> </rules> </rewrite> <iisnode debuggingEnabled="true" devErrorsEnabled="true" debuggerPathSegment="debug" nodeProcessCommandLine="&quot;%programfiles(x86)%\nodejs\node.exe&quot;" logDirectory="..\..\LogFiles\nodejs" watchedFiles="*.js;iisnode.yml;node_modules\*;views\*.jade;views\*.ejb;routes\*.js" /> </system.webServer> </configuration> 

我不知道是否iisnode (iis的路由请求到node.js的扩展)负责覆盖我的错误页面,或如果iis本身负责。 有什么build议么?

没关系,我发现这个问题。 如果其他人有相同的问题,只需在web.config中的<system.webServer>下添加以下内容:

 <httpErrors existingResponse="PassThrough" /> 

有与Windows Azure托pipe的MVC项目类似的问题。 在IIS下托pipe的本地机器工作正常,但在实机上我得到以下错误“您正在寻找的资源已被删除,名称已更改,或暂时不可用。

在system.webServer下添加这个到web config保存了我的一天

我的web.config看起来像这样

 <system.web> *** <customErrors mode="RemoteOnly" defaultRedirect="~/Error/PageNotFound"> <error statusCode="404" redirect="~/Error/PageNotFound" /> <error statusCode="500" redirect="~/Error/ServerError"/> </customErrors> </system.web> *** <system.webServer> <httpErrors existingResponse="PassThrough" /> </system.webServer>