Warning: file_get_contents(/data/phpspider/zhask/data//catemap/0/azure/13.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Windows Azure网站正在覆盖my node.js应用程序中的404和500错误页面_Node.js_Azure_Web Config_Iisnode - Fatal编程技术网

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

Windows Azure网站正在覆盖my node.js应用程序中的404和500错误页面,node.js,azure,web-config,iisnode,Node.js,Azure,Web Config,Iisnode,我正在使用Windows Azure网站托管node.js应用程序。到目前为止,一切都很好,除了我的自定义错误。在我的节点应用程序中,我有一个错误处理程序,可以在本地机器上呈现自定义404和自定义500错误页面。但是,一旦我发布到azure,当我将statusCode设置为除200以外的任何值时,它就会覆盖响应 如果我没有将500或404状态码传递给响应,则不会发生这种情况,但我确实希望状态码传递给浏览器。在本地,我的自定义错误页面很好: 但是,在azure网站上,它只返回一行文本: 由于发生

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

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

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

由于发生内部服务器错误,无法显示该页

我尝试创建自己的web.config来覆盖默认的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>
<httpErrors existingResponse="PassThrough" />


我不确定是
iisnode
(将请求路由到node.js的iis扩展)覆盖了我的错误页面,还是iis本身负责。有什么建议吗?

没关系,我发现了问题。如果其他人有相同的问题,只需在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>
<httpErrors existingResponse="PassThrough" />

在WindowsAzure中托管的MVC项目也有类似的问题。在IIS托管的本地计算机上工作正常,但在实时计算机上,我收到以下错误:“您正在查找的资源已被删除、名称已更改或暂时不可用。”

将此添加到system.webServer下的web配置中可以节省我的时间

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

***
***

这对我不起作用,原因是我的web.config中有一个
部分。移除它为我修复了它:谢谢@MattGreer提供的信息。是您自己添加的
元素,还是Azure网站default web.config中新增的元素?如果它是默认web.config的一部分,那么我想更新此答案以反映您的更正。我自己添加它是为了让IIS为SVG服务(默认情况下不会这样做)