我得到一个错误,每次我上传我的webapp到提供商。由于使用了customErrors模式,我所看到的是默认的“运行时错误”消息,指示我关闭customErrors以查看有关错误的更多信息。

我恼怒地织好了网。配置如下所示:

<?xml version="1.0"?>
<configuration>
    <system.web>
        <customErrors mode="Off"/>
    </system.web>
</configuration>

然而,我所得到的只是一个愚蠢的远程错误页面,上面没有任何有用的信息。 我还能做什么来关闭customErrors ?!


当前回答

在过去的几天里,这已经把我逼疯了,无法回避,但最终还是弄明白了:

在我的机器里。我在<system.web>下有一个条目:

<deployment retail="true" />

这似乎覆盖了你在web中指定的任何其他customError设置。配置文件,因此将上述条目设置为:

<deployment retail="false" />

现在意味着我可以再次看到我需要的详细错误消息。

这台机器。配置位于

32位

%windir%\Microsoft.NET\Framework\[version]\config\machine.config

64位

%windir%\Microsoft.NET\Framework64\[version]\config\machine.config

其他回答

“Off”区分大小写。

检查“O”在你的网页中是否是大写的。配置文件,我已经遭受了几次(简单,因为它听起来)

如果你正在使用MVC预览4,你可能会遇到这种情况,因为你正在使用HandleErrorAttribute。行为在5中改变了,因此如果关闭自定义错误,它将不处理异常。

我也遇到过同样的问题,我查看了事件查看器应用程序日志,其中清楚地提到了发生这种情况的异常。在我的情况下,例外如下…

异常信息:

Exception type: HttpException 
Exception message: The target principal name is incorrect.  Cannot generate SSPI context.
at System.Web.HttpApplicationFactory.EnsureAppStartCalledForIntegratedMode(HttpContext context, HttpApplication app)
at System.Web.HttpApplication.RegisterEventSubscriptionsWithIIS(IntPtr appContext, HttpContext context, MethodInfo[] handlers)
at System.Web.HttpApplication.InitSpecial(HttpApplicationState state, MethodInfo[] handlers, IntPtr appContext, HttpContext context)
at System.Web.HttpApplicationFactory.GetSpecialApplicationInstance(IntPtr appContext, HttpContext context)
at System.Web.Hosting.PipelineRuntime.InitializeApplication(IntPtr appContext)

The target principal name is incorrect.  Cannot generate SSPI context.

我刚刚在应用程序池中更新了我的密码,它为我工作。

在你的web.config中有像æøå这样的特殊字符吗?如果是这样,请确保编码设置为utf-8。

如果您正在进行配置转换,您可能还需要从相关web中删除以下行。配置文件。

<compilation xdt:Transform="RemoveAttributes(debug)" />