-->

Windows Azure的网站是压倒我的404个500错误页面在我的Node.js应用(Windo

2019-07-20 18:03发布

我使用的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="&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本身负责。 有什么建议?

Answer 1:

那么请不要介意,我发现这个问题。 如果其他人是具有同样的问题简单地添加在下列<system.webServer> web.config中:

<httpErrors existingResponse="PassThrough" />


Answer 2:

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

添加这web配置下system.webServer救了我的一天

我的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>


文章来源: Windows Azure Websites is overriding my 404 and 500 error pages in my node.js app