简体   繁体   English

30秒后在ASP.NET上超时,在SQL Server 2008 R2上没有超时

[英]Timeout on ASP.NET after 30 seconds, on SQL server 2008 R2 no timeout

I have a ASP.NET MVC3 project accessing a SQL server 2008 R2 database. 我有一个访问SQL Server 2008 R2数据库的ASP.NET MVC3项目。 If I run a statement in runtime, I get a timeout after 30 seconds. 如果我在运行时中运行一条语句,则会在30秒后超时。 When running the same statement in SQL server management studio there is no timeout and I get a result after 3 seconds which is acceptable. 在SQL Server Management Studio中运行同一条语句时,没有超时,并且3秒钟后我得到了可接受的结果。 While this is a test environment it seems I am the only person having sleeping processes from open windows in my management studio. 虽然这是一个测试环境,但似乎我是管理工作室中唯一拥有从打开的窗口进入休眠过程的人。 To get access to the SQL server I use System.Data.SqlClient and have the connection string stored in the web.config When a controller wants to access the database I fetch the connection string 为了访问SQL Server,我使用System.Data.SqlClient并将连接字符串存储在web.config中。当控制器想要访问数据库时,我获取连接字符串

Data Source=192.168.111.111;Initial Catalog=agkamed_dev;Persist Security Info=True;User ID=test;Password=wrongpassword;MultipleActiveResultSets=true;

and in addition set 和另外一套

SET TRANSACTION ISOLATION LEVEL SNAPSHOT

Please ask, if any further information is required. 请询问是否需要任何进一步的信息。

Question: What is responsible for the long delay on ASP.NET side? 问题:造成ASP.NET端长时间延迟的原因是什么?

Differences in performance / result of a query executed from C# and SQL Server Management Studio are often attributable to differences in ANSI settings. 从C#和SQL Server Management Studio执行查询的性能/结果差异通常归因于ANSI设置差异。

Note that SSMS will by default set ANSI_NULLS, ANSI_PADDING, ANSI_NULLS on, which won't be the case for C# (see Tools/Options/Query Execution/SQL Server/ANSI) 请注意,SSMS默认情况下会将ANSI_NULLS,ANSI_PADDING和ANSI_NULLS设置为on,而C#则不会这样(请参阅工具/选项/查询执行/ SQL Server / ANSI)。

I would suggest you experiment with setting these off one by one until you get the same behaviour as your C# code. 我建议您尝试将它们逐一设置,直到得到与C#代码相同的行为。 Then modify your query so that it isn't dependent on these settings. 然后修改您的查询,以使其不依赖于这些设置。

I couldn't find an answer to that problem yet. 我尚未找到该问题的答案。 I sailed around that error by creating a function on the SQL server, although I'd rather find a solution for the problem because it isn't the first that this issue came up. 我通过在SQL Server上创建一个函数来解决该错误,尽管我宁愿为该问题找到解决方案,因为这不是第一次出现此问题。

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

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