Server.Transfer fails because httpcontext.current = nothing

G

Guest

Hi,
I'm using Threads, and when I try to do Server.Transfer, I recieved an
error. (child object does not exist...)

My Code:

Dim t As New Thread(AddressOf Hilo)

Private Sub Hilo()
Thread.Sleep(1000)
Server.Transfer("Index.aspx")
end Sub

In Page Load I use:
t.Start()

The Thread works fine, but fails in Server.Transfer. I notice
Httpcontext.current is nothing inside "Private Sub Hilo()", but it isn't in
PageLoad, so the sentence Server.Transfer fails.


I've tried to declare a httpcontext variable and set the value of
httpcontext.current in page load.
i.e. Dim HT as httpcontext

And inside PageLoad:
HT = httpcontext.current.

It works in pageload, but inside Sub Hilo, HT is nothing as well.

Any Idea?
 
P

Patrice

Basically you launch a new thread that waits (and the HTTP requests ends
during this time) and once the HTTP request is over you want to transfer the
flow control for the "current" request to some other page (but the request
is already over so it fails).

What do you want to do ?

Note also that before investigating multithreading you also have built-in
mechanism in ASP.NET that should be likely favored over custom
multithreading (for example asynchronous web service calls).
 
B

bruce barker

your page sent its response and its context was released before the
thread completed. in prerender you should do a join back to the thread.
this way the thread an send data to the browser.

-- bruce (sqlwork.com)
 
G

Guest

The Page I'm loading has an <IFRAME> tag with a form inside which is submited
automatically in OnLoad Event, just after its fields are filled with hidden
values.

The form is submitied to an external server, and this external server
inserts a data in a database.

My page must be waiting until the data was intersed, and then, not before, I
have to do a response.redirect or server.transfer to another page.

I use a thread to be searching in the database to know when the data has
been inserted.
 
G

Guest

Hi Bruce,

I can't do a join back, because I need the aspx page was loaded completely,
so I use the thread in that way.

I explain you what I want to do.

The Page I'm loading has an <IFRAME> tag with a form inside which is
submited automatically in OnLoad Event, just after its fields are filled with
hidden values.

The form is submitied to an external server, and this external server
inserts a data in a database.

My page must be waiting until the data was intersed, and then, not before, I
have to do a response.redirect or server.transfer to another page.

I use a thread to be searching in the database to know when the data has
been inserted.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,755
Messages
2,569,536
Members
45,012
Latest member
RoxanneDzm

Latest Threads

Top