在何处以及如何定义对于我的 asp.net MVC 3 Web 应用程序
我想将客户错误设置为 true,以防止用户查看有关我的应用程序的详细信息。但我找不到应该在哪里编写此
;它应该在 web.config 中还是在 web、debug.config 中还是其他地方?
BR
I want to set the custome error to be true to prevent users from viewing detailed info about my application. But I cannot find where I should write this <customErrors mode="on">
; should it be in the web.config or in the web, debug.config or else where?
BR
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
根据我的经验,我们应该在发布模式下将自定义错误打开,并在调试模式下将其关闭。要自动执行此操作,我们可以使用 web.config 转换,如下例所示。
Web.Debug.config
此设置将允许 Web 服务器显示包含有用错误信息的 ASP.NET 黄页。
Web.Release.config
另一方面,我们不希望用户知道技术错误。我们应该使用自定义错误页面而不是 ASP.NET 黄页。
From my experience, we should turn custom error to On in release mode and turn it off in debug. To automatically do this, we can use web.config transformation like the following example.
Web.Debug.config
This setting will allow web server to display ASP.NET yellow page that contain useful error information.
Web.Release.config
In the other hand, we don't want user to know technical error. We should use custom error page instead of ASP.NET yellow page.
这取决于具体情况,但通常应该位于 Web.config 文件中。
Web.Debug.config 和 Web.Release.config(以及其他配置变体)用于部署应用程序时。当您执行发布操作时,转换会在部署期间应用到您的 Web.config 文件,这意味着您可以将特定的配置设置应用于调试、发布以及您已设置的其他配置。
如果您在开发过程中通常不执行发布操作,则需要将此设置应用于 Web.config 文件才能使其生效。
请参阅 http://msdn.microsoft.com/en-us/library/dd465318。 aspx 了解有关转换 Web.config 文件的更多详细信息。
请参阅http://msdn.microsoft.com/en-us/library/h0hfz6fc。 aspx 查看将 customErrors 元素添加到 Web.config 文件的示例。
This will depend, but normally should be in the Web.config file.
The Web.Debug.config and Web.Release.config (and other configuration variations) are used for when you deploy your application. When you perform a publish operation, the transform is applied to your Web.config file during deployment, which means you can have specific configuration settings applied for debug, release, and other configurations that you have set up.
If you don't normally perform a publish operation during development, then you will need to apply this setting to the Web.config file in order for it to take affect.
See http://msdn.microsoft.com/en-us/library/dd465318.aspx for more details about transforming the Web.config file.
See http://msdn.microsoft.com/en-us/library/h0hfz6fc.aspx for an example of adding the customErrors element to the Web.config file.
放入 Web.config 并创建重定向错误页面。
在 MVC 中,您有 HandleErrorAttribute,将其标记在类上以处理意外错误,记录它并抛出错误页面。自定义错误是具有已知状态代码的特定错误的默认页面。
Put in in Web.config and create an error page for redirect.
In MVC, you have HandleErrorAttribute, mark it on class to handler unexpected error, logged it and throw error page. Custom Error is default page for specific error with known status code.