Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calling a DLL from ASP 1

Status
Not open for further replies.

n2ckb

Programmer
Jun 8, 2001
65
GB
Hi,

I have built an application that extracts data from a spreadsheet, imports relevant data into a SQL Server database and then creates a new spreadsheet with the data formatted to the user's requirements.

The code is currently in Access, but only in the sense that it a front-end for the user. There is now a requirement for a web front end to take requests for Excel reports.

My idea is that I create a DLL that contains the code for the report creation and reference the DLL from the ASP page. The problem is that the reports can take about 20 minutes to extract all of the data. My question is whether I can call the DLL from the ASP page, let the DLL process the report on the web server in the background, and the ASP page let the user know that it will be ready soon. Will the ASP page wait for a response from the DLL before moving onto the next line of ASP code? If I set the object to nothing in the ASP page I am assuming this will close the DLL. If anyone has any advice or suggestions I would appreciate it.
 
I am thinking that the way forward may be an ActiveX EXE, rather than a DLL.... Has anyone got any experience of this as an option?

Cheers,

Nick
 
If I were you I'd make a database table for incoming report requests. The table would have fields for whatever options are on the report and also a field for an email address to use as notification when the report generation is complete.... and maybe also timestamp fields for when the report was requested, when processing was started, and when processing was completed.

Next I would make an ASP to insert a report request into the table.

Then I would make an EXE with no user interface... This program reads from the database table, takes the next highest priority request, updates the process starting date, generates the report, and sends the email notification, and updates the process complete time.

This EXE program would either be a "service" type program that is always running and polling the report request table or, even easier, it would be fired off every X minutes as a recurring task using the windows task scheduler.

Finally I would make another ASP or 2 to view/manage/purge the report requests table.
 
I use a DLL for validation of data entered on-line for the user. The ASP waits for its completion - I'm not sure if it might be possible to call it in a different way to achieve the simultaneous execution you are looking for.
 
Will the ASP page wait for a response from the DLL before moving onto the next line of ASP code?
Yes but nobody waits 20 minutes for a page to load and you may need to change the web server configuration to prevent IIS from deciding that the ASP has simply hung up and timed out.
 
Hi Sheco,

The ASP waiting for a response is what I thought would happen - totally agree - no one will wait that long and I have ruled it out. I like the sound of what you have suggested, one advantage being that I can store the requests from the users and potentially reuse Excel reports stored on the server.

I am looking at the option of ActiveX exes, that appear to be able to let the calling ASP page continue whilst processing is carried on "behind the scenes". If this allows mulithreading, it may avoid the need to queue the requests.

Thanks all.

Nick
 
I'm not clear on why you want an ActiveX EXE over a plain EXE.

If the ActiveX EXE is launched when an ASP creates an instance of one of its public classes then doesn't it have has the same problem of its COM reference count falling to zero when the ASP code is complete? So couldn't it then be terminated before finishing the 20 minutes work? Could you get around this by running it inside a MTS/COM+ package?

Wouldn't it be more straightforward to do a plain EXE that is launched every few mins by the system schedule or a windows service that spends most of its time sleeping and just wakes up every few mins to poll for new work to be done?
 
... store the requests from the users and potentially reuse Excel reports stored on the server
Also if it can take 20 mins to run then you know some morons will request the exact same report 3 times because they are impatient... if you keep the previous requests you could put up a message saying that they need to just hang on and wait for the thing to finish.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top