在何处以及如何定义< customErrors mode =“ on”>对于我的asp.net MVC 3 Web应用程序 [英] Where and how to define <customErrors mode=”on”> for my asp.net MVC 3 web application

查看:95
本文介绍了在何处以及如何定义< customErrors mode =“ on”>对于我的asp.net MVC 3 Web应用程序的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将自定义错误设置为true,以防止用户查看有关我的应用程序的详细信息。但是我找不到应该在哪里写这个< customErrors mode = on> ;。应该在web.config还是在Web,debug.config还是在其他位置?

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.config转换。

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

此设置将允许Web服务器显示包含有用错误信息的ASP.NET黄页。

This setting will allow web server to display ASP.NET yellow page that contain useful error information.

<customErrors mode="Off" xdt:Transform="Replace" />

Web.Release.config

另一方面,我们不希望用户知道技术错误。我们应该使用自定义错误页面而不是ASP.NET黄页。

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.

<customErrors mode="On" xdt:Transform="Replace" />

这篇关于在何处以及如何定义&lt; customErrors mode =“ on”&gt;对于我的asp.net MVC 3 Web应用程序的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆