增加每页级别的 ASP.Net 超时

发布于 2024-09-07 00:42:29 字数 109 浏览 2 评论 0原文

是否可以增加单个 ASP.net 页面的超时时间。我知道这在服务器级别是可能的,但是在页面级别可能吗?

单个报告页面吗?

我需要这个用于需要 2-3 分钟才能加载任何想法的

Is it possible to increase the timeout for a single ASP.net page. I know it is possible at the server level, but is it possible at thepage level?

I need this for a single report page that takes 2-3 minutes to load

any ideas?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(3

动次打次papapa 2024-09-14 00:42:29

我认为您正在寻找的是ScriptTimeout。您可以像这样在页内设置:

Page.Server.ScriptTimeout = 60;

超时值以秒为单位。

另外,请注意,如果您在调试模式下运行,这将被忽略并且超时设置为最大值;不过,我认为这对您来说不是问题,因为您是在增加超时,而不是减少超时。

I think what you're looking for is ScriptTimeout. You can set this in-page like this:

Page.Server.ScriptTimeout = 60;

The timeout value is in seconds.

Also, be aware of the fact that if you are running in debug mode, this gets ignored and the timeout is set to the maximum; I don't think that's an issue for you anyway though, as you're increasing the timeout, not decreasing it.

肤浅与狂妄 2024-09-14 00:42:29

根据 此页面,我也可以验证,这是实现的另一种好方法这是为了将其添加到您的配置的 configSection 中:

  <location path="~/MyPage.aspx">
    <system.web>
      <httpRuntime executionTimeout="600"/>      
    </system.web>    
  </location>

然后,您还可以添加其他属性,例如 maxRequestLength="204800" 或其他部分,例如:

  <location path="~/MyPage.aspx">
    <system.web>
      <httpRuntime executionTimeout="6000" maxRequestLength="204800" />      
    </system.web>    
    <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="209715200" />
        </requestFiltering>
      </security>
    </system.webServer>
  </location>

希望这有帮助。

As per this page, and I could verify too, another good way to achieve this is to add this to your config's configSection:

  <location path="~/MyPage.aspx">
    <system.web>
      <httpRuntime executionTimeout="600"/>      
    </system.web>    
  </location>

You could then also add other attributes like maxRequestLength="204800" or other sections, like:

  <location path="~/MyPage.aspx">
    <system.web>
      <httpRuntime executionTimeout="6000" maxRequestLength="204800" />      
    </system.web>    
    <system.webServer>
      <security>
        <requestFiltering>
          <requestLimits maxAllowedContentLength="209715200" />
        </requestFiltering>
      </security>
    </system.webServer>
  </location>

Hope this helps.

落花浅忆 2024-09-14 00:42:29

我发现我的问题通过增加 SQL 超时得到解决,
使用command.CommandTimeout = 100;
例子:

using (var connection = new SqlConnection(connectionString)) 
{
  connection.Open();
  SqlCommand command = new SqlCommand(queryString, connection);
  // Setting command timeout to 100 seconds
  command.CommandTimeout = 100;
  command.ExecuteNonQuery();
}

Ive found my problem was resolved by increasing the SQL timeout,
using command.CommandTimeout = 100;
example:

using (var connection = new SqlConnection(connectionString)) 
{
  connection.Open();
  SqlCommand command = new SqlCommand(queryString, connection);
  // Setting command timeout to 100 seconds
  command.CommandTimeout = 100;
  command.ExecuteNonQuery();
}
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文