Solved

Send HTML back to the user before ISAPI exits

Posted on 1999-01-15
2
176 Views
Last Modified: 2013-11-20
Hi,

I’m programming an ISAPI Dll using Ms VC++ 5.0
After requesting the function “housekeep “ of this dll, the dll will start cleaning databases and tmp files.
Because this housekeep can take up to 10 minutes I only want to report housekeep is started ( by html).
Because the html queue is only flushed if the thread ( function call ) is ended the user needs to wait 10 minutes before he receives this message. How can I directly send the html message and continue the housekeep ( complete housekeep report will be sended afterward by email ). I have tried to override the httpextensionproc but that seems no solution. Maybe someone can help with source code or suggestions to direct send html back to the client instead of waiting the thread exits …

Thanks in advanced,
Ron Daemen

0
Comment
Question by:Daemen
2 Comments
 
LVL 86

Expert Comment

by:jkr
Comment Utility
Well, i'm not familiar with ISAPI programming, but the situation is well known to me...
So, why don't you simply start a worker thread in 'housekeep' that does the actual work and return from the function immediately?
0
 
LVL 11

Accepted Solution

by:
mikeblas earned 50 total points
Comment Utility
I'll assume you're using MFC, since you've asked this in the MFC area. (You didn't specify...)

You can send a response back immediately by calling CHttpServerContext::WriteClient(). That makes you responsible for writing all the headers, as well.

You can do whatever work you want to. Spawning an extra thread as jkr suggests is the core of the solution, but it's not quite so simple in ISAPI because you have a very special operating environment. First, you'll wnat to be able to recover the therad if it hangs.  Secodn, you'll need to make sure the newly created thread gets the appropriate security context. You'll want to call GetSecurityToken() on the thread you got from IIS, and then call ImpersonateloggedInUser() with the token you get back to make the secondary thread act like the right security context.

Of course, you'll call RevertToSelf() when it's all done.

B ekiM




0

Featured Post

What Should I Do With This Threat Intelligence?

Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

Join & Write a Comment

Introduction: Load and Save to file, Document-View interaction inside the SDI. Continuing from the second article about sudoku.   Open the project in visual studio. From the class view select CSudokuDoc and double click to open the header …
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
This video will show you how to get GIT to work in Eclipse.   It will walk you through how to install the EGit plugin in eclipse and how to checkout an existing repository.
It is a freely distributed piece of software for such tasks as photo retouching, image composition and image authoring. It works on many operating systems, in many languages.

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now