简体   繁体   English

数据库关闭时如何显示自定义消息

[英]How to show the custom message when database down

I have deployed the web application and customer accessing web application publically in between my databse down then I want show the custom message to the user. 我已经部署了Web应用程序,并且客户在我的数据库之间公开访问了Web应用程序,然后我想向用户显示自定义消息。 In my web application 50 pages, and I want to handle message commonly for all pages. 在我的Web应用程序中有50个页面,并且我想共同处理所有页面的消息。 Please help how to do this. 请帮助如何执行此操作。

You can configure a section in web.config that tells ASP.NET/IIS to redirect users to a set of static or dynamic pages in case of common errors. 您可以在web.config中配置一个部分,该部分告诉ASP.NET/IIS在发生常见错误时将用户重定向到一组静态或动态页面。

Check out this article - http://www.asp.net/hosting/tutorials/displaying-a-custom-error-page-cs 查看本文-http: //www.asp.net/hosting/tutorials/displaying-a-custom-error-page-cs

The scenario is pretty similar - something goes wrong with the SQL DB call and you dont want to display an ugly error. 这种情况非常相似-SQL DB调用出了点问题,并且您不想显示难看的错误。

Make sure to include some sort of logging somewhere so that you know these errors are happing, however. 确保在某处包括某种日志记录,以便您知道这些错误正在发生。 One plus side of ugly error messages are that you'll hear about them right away ;) 丑陋的错误消息的一个好处是,您会立即听到它们;)

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

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