Solved

Send HTML back to the user before ISAPI exits

Posted on 1999-01-15
2
186 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
ID: 1327753
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
ID: 1327754
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

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

In this article, I'll describe -- and show pictures of -- some of the significant additions that have been made available to programmers in the MFC Feature Pack for Visual C++ 2008.  These same feature are in the MFC libraries that come with Visual …
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.

856 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