I am using an Application server for calling Oracle Reports and I have a URL to call the report. When the report is called the server converts it into PDF but when report contains large data it takes a lot of time to load. I want to do in asp.net that when I call the report url it opens the PDF file and copies it into the root of my web folder. The next time when I call the URL it opens the PDF file and creates a new PDF on backend for next call.
I have made this function to download file
Sub DownloadFile_Sap()
Dim remoteuri As String = "http://appsrv01.shakarganj.com.pk:7778/reports/rwservlet?reptest&report=sap_dashboard"
Dim filename As String = Server.MapPath("~/Files/rwservlet_reptest&report=sap_dashboard.pdf")
Dim mywebClient As New Net.WebClient()
mywebClient.DownloadFile(remoteuri, filename)
End Sub
and I called it on linkbutton – code is below
Protected Sub LinkButton1_Click(ByVal sender As Object, ByVal e As System.EventArgs) Handles LinkButton1.Click
ClientScript.RegisterStartupScript(Me.GetType(), "openfile", "window.open('http://202.125.144.34:83/Files/rwservlet_reptest&report=sap_dashboard.pdf');", True)
DownloadFile_Sap()
End Sub
But when I call this method on link button it gets same time as it got on download file. What can I do so that the Link button calls the file from the folder in a second and downloads the file on the backend?
Link button code is here
<asp:linkbutton ID="Linkbutton1" runat="server" PostBackUrl="~/Files/rwservlet_reptest&report=sap_dashboard.pdf" OnClick="DownloadFile_Sap" >LinkButton</asp:linkbutton>
Multithreadingin asp.net web application is not a good idea.You have limited source on
IIS thread pooland if you try to use this in a such operation,you will have serious problems on production.
So what you can do it, split to
Windows service. Do all expensive operations on windows service application. Make the communication between your web app and windows service app throughsql table.EDIT:
Here the path for this:
You will have to visual studio projects
1- your web app(you have alrady it)
2- new project that will run as windows service.
Then you will have sql table containing:
Report_Name, Ready_Flag
From web app you fill Report_Name
From windows service report is prepared and set Ready_Flag to true
You can query from web app Ready_Flag if set true, once it is true,
you serve to client