處理我有我的Web.Release.config以下相對不變MVC4項目:自定義錯誤與MVC4
<system.web>
<customErrors mode="On" defaultRedirect="~/Error">
<error redirect="~/Error/NotFound" statusCode="404" />
</customErrors>
</system.web>
它不工作,雖然 - 我得到正常的錯誤頁面,在Release模式時。
如果我將該代碼放在我的Web.Config中,它按預期工作。我只想在釋放時應用這個。
我也試過這web.release.config:
<system.web>
<customErrors mode="On" defaultRedirect="~/Error" xdt:Transform="Replace">
<error redirect="~/Error/NotFound" statusCode="404" />
</customErrors>
<compilation xdt:Transform="RemoveAttributes(debug)" />
</system.web>
無濟於事。
爲什麼會發生這種情況?
更新:如果我用我的Global.asax如下:
void Application_Error(object sender, EventArgs e)
{
#if DEBUG
#else
Response.Redirect("/Error");
#endif
return;
}
我獲得所需的行爲。我覺得我應該只能使用web.config設置......所以我想打開它。