13.0统一配置友好性错误页面

1、在网站跟目录下的web.config 的<system.web>节点下配置
 <customErrors mode="On" defaultRedirect="Error">
      <error statusCode="404" redirect="Error404"></error>
    </customErrors>
 其中:mode
 on:表示任何人访问此网站都可以看到友好性错误页面
 RemoteOnly:只有远程访问的用户才可以友好性错误页面,但是本机访问则还是看到原始的错误信息
 off:关闭友好性页面的提示
 
2、指定 Shared/Error.cshtml的视图类型为 HanderErrorInfo 就可以在页面上显示异常信息
 
 //将aspx视图引擎移除:在Global.asax中的 Application_Start()加入如下代码即可:
  ViewEngines.Engines.RemoveAt(0);

posted on 2015-05-10 17:15  阿兴的平凡世界  阅读(127)  评论(0)    收藏  举报

导航