By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
440,742 Members | 793 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 440,742 IT Pros & Developers. It's quick & easy.

custom HttpHandler question

P: n/a
I am trying to create a custom HttpHandler that will load a page but keep
the response object open while waiting for a message from a MessageQueue.
In the ProcessRequest method I call:

public void ProcessRequest(HttpContext context)
{
HttpResponse response = context.Response;
response.Buffer = false;
response.BufferOutput = false;
StringBuilder sb = new StringBuilder();
sb.Append("<HTML>\n<HEAD></HEAD>\n<BODY ");
sb.Append("bgcolor=\"black\" text=\"white\">\n");
response.Write(sb);
response.Flush();
response.Write("(" + DateTime.Now.ToString() + ") SignOn.");
response.Flush();

try
{
msgQ.ReceiveById(context.Session.SessionID, TimeSpan.FromSeconds(30));
}
catch (Exception ex)
{
response.Write("Error: " + ex.Message + "<BR>");
response.Flush();
}
sb = new StringBuilder();
sb.Append("</BODY>\n</HTML>\n");
response.Write(sb);
response.Flush();
}

After the handler receives the message from the MessageQueue, or the 30
second timeout occurs, the ProcessRequest method returns. What I am having
a problem with is that I want the portions of the page up to the sign on
message to be displayed while the process waits on the message from the
MessageQueue.

If I rem out the try/catch block shown above, the rest of the handler works
as expected.

Does anyone have any ideas how I might make this work?

Thanks in advance,

Dale


Nov 18 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Hi,

I try your code (loop instead of MQ) and it is working just fine.

SignOn displayed first and after 2-3 secound "Finish Process" displayed.

public void ProcessRequest(HttpContext context)
{
HttpResponse response = context.Response;
response.Buffer = false;
response.BufferOutput = false;
StringBuilder sb = new StringBuilder();
sb.Append("<html>\n<head></HEAD>\n<body ");
sb.Append("bgcolor=\"black\" text=\"white\">\n");
response.Write(sb);
response.Flush();
response.Write("(" + DateTime.Now.ToString() + ") SignOn.");
response.Flush();

try
{
string s = "";
for(long i=0;i < 10000;i ++)
{
s += i.ToString();
}
}
catch (Exception ex)
{
response.Write("Error: " + ex.Message + "<BR>");
response.Flush();
}
response.Write(" <BR> (" + DateTime.Now.ToString() + ") Finish
Process.");
response.Flush();

sb = new StringBuilder();
sb.Append("</body>\n</html>\n");
response.Write(sb);
response.Flush();
}
Natty Gur[MVP]

blog : http://weblogs.asp.net/ngur
Mobile: +972-(0)58-888377
*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 18 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.