处理我有我的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设置......所以我想打开它。