Jakob Gade
Jakob Gade

Reputation: 12419

Instruct the browser not to wait for more content while processing continues

How do I instruct the browser not to expect any more content to be coming down the line? Kinda like the server saying “I got what I need, you don’t need to wait while I finish the processing of the page”.

I have a server-side task, which is initiated when a certain page is hit. The task may be time-consuming, but the rendered HTML will always be the same, i.e. like a “Thank you for starting the task” message.

I’m considering starting a new thread to handle the task, but I believe there must be a more elegant solution, where you just send the right headers/instructions to the browser and then continue processing.

Any ideas?

Upvotes: 0

Views: 214

Answers (1)

Rex M
Rex M

Reputation: 144112

This will send your message to the browser:

Response.Flush()

However, I believe the responsibility of notifying the client that the transmission is complete is done by IIS, which it will not do until the ASP.NET engine finishes it's part of the request and passes control back to IIS. Your best bet is to start a new thread, which should not cause any problems since the request thread will end almost immediately after the new one begins... you still only have one thread per request.

Upvotes: 2

Related Questions