這裏的情況: -ASP.Net。爲什麼我沒有看到我的defaultRedirect頁甚至當的customErrors模式= 「開」
我在web.config中有
<customErrors mode="On" defaultRedirect="error.html" />
。
我還在Application_Error
(在global.asax.cs中)中定製了錯誤處理代碼,用於檢查某些衆所周知的異常類型並將其重定向到每個錯誤頁面。如果異常不是衆所周知的類型,那麼我從Application_Error
簡單返回而不需要調用Server.ClearError()
,所以默認的自定義處理應該照顧顯示頁面error.html。
但是,每當我的應用程序拋出了一個未處理的(而不是衆所周知的)例外,我在默認的Asp.Net錯誤頁面結束 - 你知道一個我的意思是,死亡的黃色屏幕...
Runtime Error Description: An application error occurred on the server. The current custom error settings for this application prevent the details of the application error from being viewed. Details: To enable the details of this specific error message to be viewable on the local server machine, please create a tag within a "web.config" configuration file located in the root directory of the current web application. This tag should then have its "mode" attribute set to "RemoteOnly". To enable the details to be viewable on remote machines, please set "mode" to "Off".
我已經檢查了顯而易見的東西(比如雙重檢查,我沒有在Application_Error
中拋出另一個錯誤,並且我沒有意外地調用ClearError。這個web應用肯定有些腥意(我做了一個測試web應用,自定義錯誤處理按預期工作) - 這應該排除在我的machine.config文件中的怪異點。
我會繼續撓撓頭腦,嘗試一些事情,但同時我想我會在這裏提出這個問題,看看有沒有人有任何好的想法。
PS。我正在使用Windows 7 Business(IIS 7.5),但在Win Server 2003(IIS6)上觀察到相同的行爲。
我們可以看到你的global.asax.cs代碼... – 2010-09-30 13:07:24
可以.Net從錯誤提出的位置找到錯誤頁面嗎?通常使用defaultRedirect =「〜/ error.html」 – Clicktricity 2010-09-30 13:16:39