2012-05-31 28 views
6

我有ASP.NET MVC 3應用程序中設置的自定義/ http錯誤,將出現錯誤。我Web.ConfighttpErrors部分看起來是這樣的:MVC 3自定義/ HTTP錯誤頁面不顯示查看例外

<httpErrors errorMode="Custom" existingResponse="Replace"> 
     <remove statusCode="400" /> 
     <remove statusCode="403" /> 
     <remove statusCode="404" /> 
     <remove statusCode="408" /> 
     <remove statusCode="500" /> 
     <remove statusCode="503" /> 
     <error statusCode="400" responseMode="ExecuteURL" path="/Error/BadRequest" /> 
     <error statusCode="403" responseMode="ExecuteURL" path="/Error/Forbidden" /> 
     <error statusCode="404" responseMode="ExecuteURL" path="/Error/NotFound" /> 
     <error statusCode="408" responseMode="ExecuteURL" path="/Error/Timeout" /> 
     <error statusCode="500" responseMode="ExecuteURL" path="/Error/InternalServerError" /> 
     <error statusCode="503" responseMode="ExecuteURL" path="/Error/ServiceUnavailable" /> 
    </httpErrors> 

我沒有設置customerErrors設置,因爲這不符合MVC很好地工作& IIS 7.5。

當代碼發生異常時,所有的代碼都可以正常工作。

但是,如果在視圖中引發異常 - 它會嘗試顯示我沒有的默認~/Views/Shared/Error.cshtml

可能拋出一個錯誤的觀點可能是這樣的:

@Html.Partial("TemplateSection", Model.PreContent) 

而且想象PreContent爲空,並且通過這樣做顯示值當TemplateSection觀點會失敗:@Model.Name

回答

1

我讀this article和自從我的結果代碼在48小時前投入生產以來沒有任何問題。給它一個旋轉。

相關問題