2013-04-22 55 views
1

我遇到的情況,404頁面不提供對擴展名的URL

我的自定義404頁的作品只是罰款與具有擴展URL。

http://www.space.ca/ssss.aspx 按照預期的自定義頁面URL提供了,

然而,如果試圖鏈接沒有.aspx擴展 http://www.space.ca/ssss

它進入IIS默認頁面。任何想法爲什麼?

這是我的配置,內部system.webserver

<httpErrors> 
      <remove statusCode="500" subStatusCode="-1" /> 
      <remove statusCode="404" subStatusCode="-1" /> 
      <error statusCode="404" prefixLanguageFilePath="" path="/errors/404.aspx" responseMode="ExecuteURL" /> 
      <error statusCode="500" prefixLanguageFilePath="" path="/errors/500.aspx" responseMode="ExecuteURL" /> 
     </httpErrors> 

回答

2

我知道,這是貼前一段,然而,這可能會幫助別人......

我有同樣的問題,它主要是向下的路徑值中有「〜」,可悲的是,這不是你的問題,但如果你遵循那麼下面的你應該沒問題......

<customErrors mode="On" redirectMode="ResponseRewrite"> 
    <error statusCode="401" redirect="~/Errors/Unauthorized.aspx" /> 
    <error statusCode="403" redirect="~/Errors/Forbidden.aspx" /> 
    <error statusCode="404" redirect="~/Errors/PageNotFound.aspx" /> 
    <error statusCode="500" redirect="~/Errors/ServerError.aspx" /> 
    <error statusCode="501" redirect="~/Errors/ServerError.aspx" /> 
</customErrors> 

<httpErrors errorMode="Custom"> 
    <remove statusCode="401" subStatusCode="-1" /> 
    <remove statusCode="403" subStatusCode="-1" /> 
    <remove statusCode="404" subStatusCode="-1" /> 
    <remove statusCode="500" subStatusCode="-1" /> 
    <remove statusCode="501" subStatusCode="-1" /> 
    <error statusCode="401" path="/Errors/Unauthorized.aspx" responseMode="ExecuteURL" /> 
    <error statusCode="403" path="/Errors/Forbidden.aspx" responseMode="ExecuteURL" /> 
    <error statusCode="404" path="/Errors/PageNotFound.aspx" responseMode="ExecuteURL" /> 
    <error statusCode="500" path="/Errors/ServerError.aspx" responseMode="ExecuteURL" /> 
    <error statusCode="501" path="/Errors/ServerError.aspx" responseMode="ExecuteURL" /> 
</httpErrors> 

當然你只東東d爲您希望爲其創建自定義頁面的狀態代碼添加條目。另請注意,httpErrors應放置在部分,並且自定義錯誤位於部分。

您可以添加customErrors部分,因爲它可以處理託管代碼。 httpErrors部分將處理所有內容的錯誤。

還請注意最後一件事......當您在本地機器上進行測試時,ASP.NET和HTTP錯誤的默認設置是顯示本地瀏覽器的詳細信息。您將需要設置customErrors mode =「On」AND httpErrors errorMode =「Custom」以便查看本地計算機上的自定義錯誤。

更多信息可以在這裏找到:http://www.iis.net/ConfigReference/system.webServer/httpErrors

+0

答案很好,我想這就是問題的答案。 – 2015-06-30 06:19:31

0

這對我的作品。

<httpErrors errorMode="Custom" existingResponse="Replace" defaultResponseMode="ExecuteURL"> 
     <clear /> 
     <error statusCode="404" path="~/error404.aspx" responseMode="Redirect" /> 
    </httpErrors>