473,387 Members | 1,585 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

custom HttpHandler question

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
1 1345
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Michael Iantosca | last post by:
I have a custom attribute that I attach to certain pages in my application and I want to inspect each page request as it is made to see if the custom attribute is attached to the underlying page...
3
by: Jed | last post by:
I have written an HttpHandler which I invoke through an ashx page. The HttpHandler does various things to process the request, then it is supposed to redirect to a confirmation page. Everything...
3
by: Ralf Müller | last post by:
hi all! in my custom HttpHandler HttpContext.Current.Session is not set - why? greetings, ralf
9
by: Jared Tullis | last post by:
We have an .NET 1.1 application running on 4 2K3 load balanced servers (using WLBS). IIS has the .NET aspnet_isapi.dll mapped as a wildcard application map. The web.config points *.html to a...
7
by: Adam | last post by:
Im trying to add an httphandler for all *.sgf file extensions. I have developed the handler, 1. installed it into the gac 2. added it to the machine.config: <httpHandlers> <add verb="*"...
8
by: bryan | last post by:
I've got a custom HttpHandler to process all requests for a given extension. It gets invoked OK, but if I try to do a Server.Transfer I get an HttpException. A Response.Redirect works, but I really...
0
by: Mutley | last post by:
Hi All, I have a custom HttpHandler that handles requests for pages with my custom file extension of sfdl. Within the ProcessRequest method of the custom handler I want then to getthe page. I...
1
by: henke.lundin | last post by:
Hello, I am having problems with Server.Transfer(string, bool) in the ProcessRequest method of a custom HTTP handler. I get the "Error executing child request" error message. The page that I am...
5
by: Author | last post by:
I followed the example at http://support.microsoft.com/kb/308001/EN-US/ and created my own HttpHandler. Here is the code: using System.Web; namespace MyNameSpace { public class...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.