2011-09-22 128 views
1

我有這樣的代碼在我的web.config文件:asp.NET - 自定義錯誤消息

<customErrors defaultRedirect="~/GeneralError.aspx" mode="On"> 
    <error statusCode="401" redirect="401.aspx" /> 
    <error statusCode="404" redirect="404.aspx" /> 
</customErrors> 

這工作完全在我的本地機器上同時運行IIS並重定向到我的錯誤頁,但是當我運行它在服務器上,IIS的默認錯誤頁面彈出而不是我的。

這是爲什麼?我怎樣才能解決這個問題?這是從代碼相關的東西,還是這是在服務器上的一些設置?

回答

0

這種格式是爲我工作

<customErrors defaultRedirect="~/GeneralError.aspx" mode="On"> 
    <error statusCode="401" redirect="~/GeneralError.aspx" /> 
    <error statusCode="404" redirect="~/GeneralError.aspx" /> 
</customErrors> 

<error statusCode="404" redirect="filenotfound.htm" />