【问题标题】:Classic ASP - Custom Error Pages经典 ASP - 自定义错误页面
【发布时间】:2013-12-09 08:18:27
【问题描述】:

我用 IIS7 全新安装了 Windows Server 2008。在那里我安装了“Classic ASP”并将调试选项“Send Errors To Browser”更改为True。

1.

我创建了一个包含 2 个文件的目录:

-- C:\inetpub\wwwroot\stadtbibliothek
 - index.asp -> <% Response.Write "Hello World" %>
 - 500-100.asp -> <% Response.Write "Error" %>

我将目录转换为应用程序并分配了我创建的应用程序池(.net 版本:无托管代码,管道代码:经典)。

然后我从远程客户端 (http://svr-name.domain/stadtbibliothek/) 测试了该页面,然后出现了“Hello World”。

2.

我在 index.asp 文件中添加了一个错误,在“stadtbibliothek”文件夹中添加了一个 web.config 文件(根目录中没有):

<?xml version="1.0" encoding="UTF-8"?>
<configuration>
    <system.webServer>
        <defaultDocument>
            <files>
                <add value="index.asp" />
            </files>
        </defaultDocument>
                <httpErrors>
                    <remove statusCode="500" subStatusCode="100" />
                    <error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
                </httpErrors>
    </system.webServer>
</configuration>

解决方案:

原来我只需要在路径中包含文件夹名称:

&lt;error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/stadtbibliothek/error.asp" responseMode="ExecuteURL" /&gt;

感谢您的建议!

【问题讨论】:

    标签: iis-7 asp-classic custom-error-pages


    【解决方案1】:

    来自documentation

    路径:必需的字符串属性。

    指定用于响应 HTTP 的文件路径或 URL statusCode 和 subStatusCode 属性指定的错误。如果你 选择文件响应模式,你指定自定义的路径 错误页面。如果您选择 ExecuteURL 响应模式,路径有 作为服务器相对 URL(例如,/404.htm)。如果您选择 重定向响应模式,你必须输入一个绝对 URL(对于 例如,www.contoso.com/404.htm)。

    尝试更改此行:

    <error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/error.asp" responseMode="ExecuteURL" />
    

    到这里:

    <error statusCode="500" subStatusCode="100" prefixLanguageFilePath="" path="/stadtbibliothek/error.asp" responseMode="ExecuteURL" />
    

    【讨论】:

      【解决方案2】:

      我认为你应该自定义错误:

      <?xml version="1.0" encoding="UTF-8"?>
      <configuration>
        <system.webServer>
          *
          *
          *
        </system.webServer>
        <system.web>
           <customErrors mode="On"/>
        </system.web>
      </configuration>
      

      【讨论】:

        猜你喜欢
        • 2015-03-24
        • 1970-01-01
        • 2017-11-16
        • 2013-01-31
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2011-02-24
        • 1970-01-01
        相关资源
        最近更新 更多