繁体   English   中英

防止应用程序超时

[英]Preventing app from running into timeout

对不起,专家的标题,我想不出更好的方法。

下面的代码接收多达20个链接,然后使用一个组件,将这20个链接转换为文档,并将这些文档存储到一个Adobe pdf文件中。

如果您传递的值小于10,那么它会起作用。以上任何内容都会破坏应用程序。

事实证明,代码中断的原因是运行时间太长。

在asp.net(c#或vb.net)中是否可以将应用程序配置为运行更长的时间而不中断?

这是在iis方面完成的吗?

如果是,有人可以指出正确的方向吗?

我知道的一件事是iis元数据库,将它设置为可以接受更大的大小,但是我不确定如何使用下面的代码来确保应用程序在花费很长时间运行时不会中断。

using System;
using System.Collections.Generic;
using System.Text;
using EO.Pdf;
using System.Collections.Specialized;
using EO.Web;

partial class getRecs : System.Web.UI.Page
{
    private void  // ERROR: Handles clauses are not supported in C#
Page_Load(object sender, System.EventArgs e)
    {

        if (!Page.IsPostBack) {
            string linksList = Request.QueryString("pid");
            string[] AllLinks = linksList.Split(",");

            //Create a PdfDocument object
            PdfDocument doc = new PdfDocument();

            string links = null;

            foreach ( links in AllLinks) {

                HtmlToPdf.ConvertUrl(url, doc);
            }

            doc.Save(Response.OutputStream);

        }
    }

}

谢谢你的帮助。

似乎您在请求超时方面遇到了问题,因为该过程花费的时间太长,无法用生成的PDfs响应客户端。 您可以在Web.config中增加“请求超时”设置:

<configuration>
  <system.web>
  <httpRuntime 
    executionTimeout="1000"/>
  </system.web>
</configuration>

executionTimeout以秒为单位设置。 根据需要进行调整。 仅当在编译元素中将debug标志设置为false时才适用。

链接到MSDN文档。

暂无
暂无

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

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