2008-12-02 24 views
2

我已經嘗試了這兩種使用和不使用'ExceptionType'參數。我在Views/Shared文件夾和Views/thisController文件夾中都有一個Error.aspx頁面。但是每次運行這個時,我都會在'/'應用程序中出現「服務器錯誤」。錯誤頁面,而不是Views/Shared中的不錯頁面。MVC測試版[HandleError]屬性(需要幫助)

任何想法在這裏可能會出錯?

[HandleError(View="Error",ExceptionType=typeof(FormatException))] 

    public ActionResult Create() 
    { 
     throw new Exception(); 
     //int breakMe = int.Parse("not a number"); 
     return View(); 
    } 

回答

3

我確實有這在我的網站.config

<customErrors mode="On"></customErrors> 

必須是其他玩法。

+0

當我將模式從RemoteOnly更改爲開時,它開始爲我工作。 – 2008-12-03 01:50:59

1

它不適用於我當前的項目或新的項目。這可能是一個「功能」。

編輯:它看起來像你的customErrors啓用(模式=「開」),它根據該段從HandleErrorAttribute.cs工作:

// If custom errors are disabled, we need to let the normal ASP.NET exception handler 
// execute so that the user can see useful debugging information. 
if (filterContext.ExceptionHandled || !filterContext.HttpContext.IsCustomErrorEnabled) { 
    return; 
}