如何:Dnn自定义错误页面

时间:2015-01-01 12:37:33

标签: asp.net error-handling dotnetnuke

默认错误页面可能会暴露大量信息,例如您使用的语言和服务器,以及此类信息。恶意用户可能会使用它来攻击您的网站和服务器。

此外,默认错误页面看起来非常丑陋和过时的设计,这可能会损害您的品牌。

因此,我们始终建议您使用自定义错误页面。

那么,发生错误时如何在DNN中显示自定义错误页面?

1 个答案:

答案 0 :(得分:0)

1.禁用DNN错误处理,让错误冒泡..

主机设置>>外观>>取消选中“使用自定义错误消息?”

2.要将用户重定向到,可以是aspx页面,但我更喜欢HTML

然后使用Style

在根目录下创建HTML页面

3.in在Web.Config中启用CustomErrors:

<customErrors mode="On">
  <error statusCode="500" redirect="/MyCustomError.html"/>
  <error statusCode="404" redirect="/MyCustomError.html"/>
  <error statusCode="403" redirect="/MyCustomError.html"/>
</customErrors>

您还可以使用以下web.config代码段覆盖IIS错误页面并重定向到自定义错误页面

<httpErrors>
  <remove statusCode="404" subStatusCode="-1"/>
  <error statusCode="404" prefixLanguageFilePath="" path="/MyCustomError.aspx" responseMode="ExecuteURL"/>
  <remove statusCode="403" subStatusCode="-1"/>
  <error statusCode="403" prefixLanguageFilePath="" path="/MyCustomError.html" responseMode="ExecuteURL"/>
</httpErrors>