How do i call an aspx page from within another aspx page and not wait for it to complete?

108 Views Asked by At

I want to call an aspx page that creates a PDF file from current aspx page but I don't want to wait for the other page to complete. It takes a long time for the PDF to be created and the user doesn't care that it is being created.

I tried Server.TransferRequest and that seems to work except the page I am working on shows the "response.write" from the page I called. I want the called page to simply run and I don't want to know about it after I call it.

How can I simply execute another page and "forget it". Unfortunately, the PDF utility is required to be run on an actual aspx page and cannot be called in a function.

Protected Sub Button3_Click(sender As Object, e As EventArgs) Handles Button3.Click

    Response.write("This should show on the current page")

    Server.TransferRequest("/Invoicing/PDFGenerator.aspx")

    Response.write("This second line should show on the current page but does not")

End Sub

I've looked at async info but it is not clear if that is what I have to do here.

1

There are 1 best solutions below

0
wazz On

The iframe approach might work. Create a hidden iframe on your page and load the .aspx page into it as needed.

// add query string if needed.
$(".hiddenIframe").attr("src", "pdf-generator.aspx?fname=" + fname + "&fid=" + fid);

When the page is loaded (via 'src') the code-behind will execute.