2014-12-06 85 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