Che*_*hev 32 web-config azure node.js iisnode
我使用Windows Azure网站来托管node.js应用程序.到目前为止,一切都很好,除了我的自定义错误.在我的节点应用程序中,我有一个错误处理程序,可以在我的本地计算机上呈现自定义404和自定义500错误页面.但是,当我发布到azure时,当我将statusCode设置为除200以外的任何值时,它会覆盖响应.
如果我没有将500或404 statusCode传递给响应,那么这不会发生,但我确实希望状态代码能够进入浏览器.在本地我得到我的自定义错误页面就好了:

但是,在azure网站上,它只返回一行文字:
由于发生内部服务器错误,无法显示页面.
我尝试创建自己的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=""%programfiles(x86)%\nodejs\node.exe""
logDirectory="..\..\LogFiles\nodejs"
watchedFiles="*.js;iisnode.yml;node_modules\*;views\*.jade;views\*.ejb;routes\*.js" />
</system.webServer>
</configuration>
Run Code Online (Sandbox Code Playgroud)
我不确定iisnode(将请求路由到node.js的iis的扩展名)负责覆盖我的错误页面或者iis本身是否负责.有什么建议?
Che*_*hev 86
没关系,我发现了这个问题.如果其他人遇到同样的问题,只需<system.webServer>在web.config中添加以下内容:
<httpErrors existingResponse="PassThrough" />
Run Code Online (Sandbox Code Playgroud)