简体   繁体   English

如何:Dnn自定义错误页面

[英]How To : Dnn Custom Error Pages

Default error pages may expose a lot of information, Like the language and the server you use, and such Info. 默认错误页面可能会公开很多信息,例如您所使用的语言和服务器以及此类信息。 could be used by malicious users to attack your site and your server. 可能被恶意用户用来攻击您的网站和服务器。

Also default error pages look very ugly and outdated design, which may harm your brand. 默认错误页面的外观也非常丑陋和过时,这可能会损害您的品牌。

So It's always recommended to use custom error pages.. 因此,始终建议使用自定义错误页面。

So, How Could I display a custom error page in DNN when error occurs ? 因此,发生错误时,如何在DNN中显示自定义错误页面?

1.To Disable DNN Error Handling, and Let Errors Bubble.. 1.禁用DNN错误处理,并让错误冒泡。

Host Settings >> Appearance >> Un-Check "Use Custom Error Messages? " 主机设置>>外观>>取消选中“是否使用自定义错误消息?”

2.To Redirect Users To, Can be aspx page, but I prefer HTML 2.To重定向用户到,可以是aspx页面,但我更喜欢HTML

Then Create HTML Page at the root with Style 然后使用样式在根目录下创建HTML页面

3.in Enable CustomErrors in Web.Config : 3.在启用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>

Also You can Override IIS Error Pages and Redirect to your Custom Error Pages using the below web.config snippet 您也可以使用下面的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>

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM