我想将客户错误设置为 true 以防止用户查看有关我的应用程序的详细信息。但是我找不到我应该在哪里写这个 <customErrors mode="on">
;它应该在 web.config 中还是在 web、debug.config 或其他地方?
BR
最佳答案
根据我的经验,我们应该在 Release模式下将自定义错误设置为 On 并在调试时将其关闭。要自动执行此操作,我们可以使用 web.config 转换,如下例所示。
Web.Debug.config
此设置将允许 Web 服务器显示包含有用错误信息的 ASP.NET 黄页。
<customErrors mode="Off" xdt:Transform="Replace" />
Web.Release.config
另一方面,我们不希望用户知道技术错误。我们应该使用自定义错误页面而不是 ASP.NET 黄页。
<customErrors mode="On" xdt:Transform="Replace" />
关于asp.net-mvc-3 - 在何处以及如何为我的 asp.net MVC 3 Web 应用程序定义 <customErrors mode=”on”>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9286113/