2014-12-06 86 views
1

我需要制作简单的404错误页面,其中可能有一些服务器端代码。对于我已web.config文件如下web.config 404页面未执行

<?xml version="1.0" encoding="UTF-8"?> 
<configuration> 
    <system.webServer> 
     <defaultDocument> 
      <files> 
       <add value="index.asp" /> 
      </files> 
     </defaultDocument> 
     <httpErrors errorMode="Custom" existingResponse="Replace" defaultResponseMode="ExecuteURL"> 
      <remove statusCode="404" subStatusCode="-1" /> 
      <error statusCode="404" prefixLanguageFilePath="" path="404.asp" /> 
     </httpErrors> 
    </system.webServer> 
</configuration> 

和404.asp页面已经以下代码

404 page 
<%=date%> 

当我请求不存在的页然后将其显示为

404页输出
<%= date%>

将asp代码直接发送到浏览器而不在服务器端执行

我怎样才能避免这种

+0

的可能重复[如何启用IIS7.5 ASP经典(http://stackoverflow.com/questions/9072048/how-to-enable- asp-classic-in-iis7-5) – 2014-12-07 08:22:39

+0

在iis中启用了asp并且其他页面也正在执行它仅对于该404页面是错误的 – user3818826 2014-12-08 07:28:28

回答

0

变化defaultResponseMode="ExecuteURL"defaultResponseMode="Redirect"。还可以使用,而不是404.asp绝对URL(如http://example.com/404.asp