468,133 Members | 1,623 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,133 developers. It's quick & easy.

Server.Transfer fails because httpcontext.current = nothing

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?
Oct 24 '07 #1
2 2847
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)

albertosoria wrote:
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?
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?

Oct 24 '07 #2
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 <IFRAMEtag 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.
"bruce barker" wrote:
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)

albertosoria wrote:
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?
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?
Oct 25 '07 #3

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by Srini | last post: by
2 posts views Thread by Mauricio | last post: by
8 posts views Thread by bryan | last post: by
reply views Thread by fabrice | last post: by
2 posts views Thread by Fabrice | last post: by
1 post views Thread by =?Utf-8?B?c2hldWVydHo=?= | last post: by
27 posts views Thread by didacticone | last post: by
1 post views Thread by gcdp | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.