D
DalePres
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
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