0

Sorry experts for the title, I could not think of a better way.

The code below receives as many as 20 links, then using a component, converts those 20 links into documents and stores these documents into one adobe pdf file.

It works if you pass along less than 10. Anything above, breaks the app.

It turns out that the reason code is breaking is because it is taking too long to run.

Is there a way in asp.net (c# or vb.net) to configure the app to run longer without breaking?

Is this done on iis side?

If yes, can someone please point me in the right direction?

The one thing I know is iis metabase to set it to accept larger sizes but I am not sure what to do with the code below to ensure app doesn't break when taking too long to run.

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);

        }
    }

}

Thanks for your help.

Olivier Jacot-Descombes
  • 104,806
  • 13
  • 138
  • 188
Kenny
  • 1,058
  • 4
  • 20
  • 49
  • 2
    When you said breaking, is it timing out? If yes you can make the default time out value longer in web.config. See the following question on how to set your time out http://stackoverflow.com/questions/1205828/set-session-timeout-in-web-config – atbebtg Aug 09 '12 at 20:49
  • Do you _have_ to download all the links immediately? Can you not do that in the background and have a status page to the the user that his PDFs are ready? – Oded Aug 09 '12 at 20:51
  • 1
    @atbebtg that answer you linked is for increasing Session timeout. It seems to me that he's having issues with *Request* timeouts. – Icarus Aug 09 '12 at 20:53
  • You are absolutely correct. Sorry about that. See Icarus's answer httpruntime timeout is what you need. Sorry – atbebtg Aug 09 '12 at 21:02
  • @Icarus, yes guys what I mean by breaking is that it is timing out, giving us, "page cannot be found" error. In other instances, the document we want is retrieved not completly. Oded, we have a checkbox that allows users to select one or more documents to print. The documents will have to be dumped into one pdf, just to prevent them having to do it one at a time, given document total of about 300 per day. – Kenny Aug 09 '12 at 21:03

1 Answers1

1

It seems that you are having issues with Request timeouts since the process is taking too long to respond to the client with the PDfs generated. You can increase the Request timeout setting in the Web.config:

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

The executionTimeout is set in seconds. Adjust according to your needs. This only applies if the debug flag is set to false in the compilation element.

Link to MSDN documentation.

Icarus
  • 63,293
  • 14
  • 100
  • 115
  • et al, thank you guys very much. I am still getting the following error: "Internet Explorer cannot display webpage" This happens when more than 15 is selected as indicated. Anything else I could try? – Kenny Aug 09 '12 at 23:45
  • @Kenny can you provide the exact HTTP Status code returned? Can you post the full details using Firebug or similar tool? – Icarus Aug 10 '12 at 00:05
  • no HTTP Status code. In addition to error this error: "Internet Explorer cannot display webpage", it also says, What you can try: Diagnose Connection Problem; More Info. This happens after attemping to pass more than 15. – Kenny Aug 10 '12 at 00:16
  • @Kenny What I mean is that you run your test once more using Firefox and enabling Firebug... Have you ever used it? It will show you exactly the status code returned by the server. IE is very good at hiding exceptions. While some browsers may display a 503 or a 500 status code, Explorer may simply display "Cannot display the page". In case you are not familiar with it, see this video: http://www.youtube.com/watch?v=2xxfvuZFHsM – Icarus Aug 10 '12 at 00:29
  • thanks for your patience. I installed the firebug, made firefox my default browser and tried running the app again and this time, it says, "We're sorry, firefox has crashed. There is a button that says click here for details but clicking it doesn't do anything. I will close it now select smaller numbers. Frustrating! – Kenny Aug 10 '12 at 00:51
  • an update. I selected 16 using firefox and it didn't give an error. However, firefox doesn't like opening pdf document. It displays unreadable characters. Is there something to be configured in firefox so it can read pdf? We are just trying what could work. – Kenny Aug 10 '12 at 01:00
  • hi @Icarus, I am going to close this question. I asked the wrong question but based on the question I asked, you provided the correct response. Sorry about any inconvenience. I will close this and ask the correct question. – Kenny Aug 10 '12 at 14:05