Asp.Net网站部署:配置debug和错误页

作者:陆金龙    发表时间:2014-10-06 00:49   


 对Web.config文件进行如下修改:

1.关于debug="false"设置

   开发调试期间设置debug为true,发布时设置为false。

<!-- 

            设置 compilation debug="true" 可将调试符号插入到已编译的页面。由于这会影响性能,因此请仅在开发过程中将此值设置为 true。

        -->

<compilation debug="true" targetFramework="4.0">

2.使用错误页防攻击

1) 准备相应的三个页面:error.htm、NoAccess.htm、FileNotFound.htm

     分别用来处理服务器错误 、用户没有访问权限、 资源不存在3中情况。可以在这3个页面自定义给用户的反馈信息。

2) 错误页配置示例:  <system.web>下配置customErrors节点

    <customErrors mode="On" defaultRedirect="error.htm">

        <error statusCode="403" redirect="NoAccess.htm"/>

        <error statusCode="404" redirect="FileNotFound.htm"/>

    </customErrors>