ASP.NET 连接闲置一段时间后超时
我的 ASP.NET 网站在一段时间不活动后首次尝试连接到数据库时抛出超时异常。
我了解连接池中的连接由于某种原因(防火墙或 Oracle 设置)在一段空闲时间后被终止,并且池或应用程序对此没有任何线索。
有没有办法预先验证连接,以便第一次尝试不会引发异常?
我对数据库或防火墙设置没有太多控制权。所以我必须处理这是我的应用程序。(如果有任何 web.config 设置,我会更喜欢)
我正在使用:ASP.NET 2.0。 Oracle 服务器 11g、Microsoft Enterprise Library DAAB 来完成我所有的数据库操作。
我对此主题进行了一些搜索,但尚未找到任何可靠的解决方案:(
My ASP.NET website while trying to connect to the database for first time after a period of inactivity throws an time out exception.
I understand the connections in the connection pool get terminated after some idle time for some reason (Firewall or Oracle settings) and the pool or app doesn't have a clue about it.
Is there any way to validate the connection beforehand so that the first try doesn't throw an exception?
I don't have much control over the DB or Firewall settings. So I have to deal with this is my application.(would prefer if there is any web.config settings)
I am using: ASP.NET 2.0. Oracle server 11g, Microsoft Enterprise Library DAAB to do all my DB operations.
I did some search on this topic but didnt find any solid solution for this yet :(
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
您可以检查 SqlConnection 上有一个 State 属性
There is a State property on SqlConnection that you could check
您始终可以增加连接超时属性
You can always increase the Connection Timeout property