473,657 Members | 2,517 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Redirect in a new thread

Hi all

When I start a new thread that tries to call:

HttpContext.Cur rent.Response.R edirect()

It fails as Current returns null, is there anyway to access the current
httpcontext from within a new thread?

Thanks
Kev
Nov 19 '05 #1
8 2163
Typically when you spawn another thread, the original request thread will
have completed and no longer be around.

If you are blocking on the request thread until your spawned is completed,
could you just not use a return value from your spawned thread?

bill

"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
Hi all

When I start a new thread that tries to call:

HttpContext.Cur rent.Response.R edirect()

It fails as Current returns null, is there anyway to access the current
httpcontext from within a new thread?

Thanks
Kev

Nov 19 '05 #2
Hi Bill

What I basically want to do is redirect the user to an aspx, but at the
server side I want it to wait until a response has been posted back from the
client side before continuing execution.

Any ideas?

Thanks
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:es******** ******@tk2msftn gp13.phx.gbl...
Typically when you spawn another thread, the original request thread will
have completed and no longer be around.

If you are blocking on the request thread until your spawned is completed,
could you just not use a return value from your spawned thread?

bill

"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
Hi all

When I start a new thread that tries to call:

HttpContext.Cur rent.Response.R edirect()

It fails as Current returns null, is there anyway to access the current
httpcontext from within a new thread?

Thanks
Kev


Nov 19 '05 #3
I am not exactly sure what you are wanting to do.

The user makes a request to Page1.aspx.
Page1.aspx starts ThreadA.
ThreadA waits until Page1.aspx has been posted from the same user.
ThreadA starts processing.

bill
"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
Hi Bill

What I basically want to do is redirect the user to an aspx, but at the
server side I want it to wait until a response has been posted back from the client side before continuing execution.

Any ideas?

Thanks
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:es******** ******@tk2msftn gp13.phx.gbl...
Typically when you spawn another thread, the original request thread will have completed and no longer be around.

If you are blocking on the request thread until your spawned is completed, could you just not use a return value from your spawned thread?

bill

"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
Hi all

When I start a new thread that tries to call:

HttpContext.Cur rent.Response.R edirect()

It fails as Current returns null, is there anyway to access the current
httpcontext from within a new thread?

Thanks
Kev



Nov 19 '05 #4
I have a class that redirects the user to a page, but I want the class to
stay "alive" until the page has been posted from the user.

As you know the Response.Redire ct stops all execution, the behaviour I want
is for the page to still post but for the execution to continue.

HTH
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:eW******** ******@TK2MSFTN GP09.phx.gbl...
I am not exactly sure what you are wanting to do.

The user makes a request to Page1.aspx.
Page1.aspx starts ThreadA.
ThreadA waits until Page1.aspx has been posted from the same user.
ThreadA starts processing.

bill
"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
Hi Bill

What I basically want to do is redirect the user to an aspx, but at the
server side I want it to wait until a response has been posted back from

the
client side before continuing execution.

Any ideas?

Thanks
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:es******** ******@tk2msftn gp13.phx.gbl...
> Typically when you spawn another thread, the original request thread will > have completed and no longer be around.
>
> If you are blocking on the request thread until your spawned is completed, > could you just not use a return value from your spawned thread?
>
> bill
>
> "Mantorok" <no**@tiscali.c o.uk> wrote in message
> news:cu******** **@newsfeed.th. ifl.net...
>> Hi all
>>
>> When I start a new thread that tries to call:
>>
>> HttpContext.Cur rent.Response.R edirect()
>>
>> It fails as Current returns null, is there anyway to access the
>> current
>> httpcontext from within a new thread?
>>
>> Thanks
>> Kev
>>
>>
>
>



Nov 19 '05 #5
Response.Redire ct( newPage, false ) -- Will continue execution and just add
the Redirect header to the outgoing request.

Response.Redire ct( newPage, true ) -- Will cause a thread abort exception
and the Redirect header to the outgoing request.

Can you not place your class in Session?

I am still not sure where the spawned thread is coming in.

bill

"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
I have a class that redirects the user to a page, but I want the class to
stay "alive" until the page has been posted from the user.

As you know the Response.Redire ct stops all execution, the behaviour I want is for the page to still post but for the execution to continue.

HTH
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:eW******** ******@TK2MSFTN GP09.phx.gbl...
I am not exactly sure what you are wanting to do.

The user makes a request to Page1.aspx.
Page1.aspx starts ThreadA.
ThreadA waits until Page1.aspx has been posted from the same user.
ThreadA starts processing.

bill
"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
Hi Bill

What I basically want to do is redirect the user to an aspx, but at the
server side I want it to wait until a response has been posted back
from the
client side before continuing execution.

Any ideas?

Thanks
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:es******** ******@tk2msftn gp13.phx.gbl...
> Typically when you spawn another thread, the original request thread

will
> have completed and no longer be around.
>
> If you are blocking on the request thread until your spawned is

completed,
> could you just not use a return value from your spawned thread?
>
> bill
>
> "Mantorok" <no**@tiscali.c o.uk> wrote in message
> news:cu******** **@newsfeed.th. ifl.net...
>> Hi all
>>
>> When I start a new thread that tries to call:
>>
>> HttpContext.Cur rent.Response.R edirect()
>>
>> It fails as Current returns null, is there anyway to access the
>> current
>> httpcontext from within a new thread?
>>
>> Thanks
>> Kev
>>
>>
>
>



Nov 19 '05 #6
Hi bill

Well, here is a typical example of what I want to do...

public class PageShower
{
public void ShowAndWait()
{
// Redirect then wake up when required
HttpContext.Cur rent.Response.R edirect("wizard .aspx", false);

// Sleep
Sleep();
}
}

I want the redirect to happen while the class waits, it will then be
subsequently woken up later on. Ignore the other thread for now, I though
threading may be able to provide a solution on this matter.

HTH
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Response.Redire ct( newPage, false ) -- Will continue execution and just
add
the Redirect header to the outgoing request.

Response.Redire ct( newPage, true ) -- Will cause a thread abort exception
and the Redirect header to the outgoing request.

Can you not place your class in Session?

I am still not sure where the spawned thread is coming in.

bill

"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
I have a class that redirects the user to a page, but I want the class to
stay "alive" until the page has been posted from the user.

As you know the Response.Redire ct stops all execution, the behaviour I

want
is for the page to still post but for the execution to continue.

HTH
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:eW******** ******@TK2MSFTN GP09.phx.gbl...
>I am not exactly sure what you are wanting to do.
>
> The user makes a request to Page1.aspx.
> Page1.aspx starts ThreadA.
> ThreadA waits until Page1.aspx has been posted from the same user.
> ThreadA starts processing.
>
> bill
>
>
> "Mantorok" <no**@tiscali.c o.uk> wrote in message
> news:cu******** **@newsfeed.th. ifl.net...
>> Hi Bill
>>
>> What I basically want to do is redirect the user to an aspx, but at
>> the
>> server side I want it to wait until a response has been posted back from > the
>> client side before continuing execution.
>>
>> Any ideas?
>>
>> Thanks
>> Kev
>>
>> "William F. Robertson, Jr." <th****@nameht. org> wrote in message
>> news:es******** ******@tk2msftn gp13.phx.gbl...
>> > Typically when you spawn another thread, the original request thread
> will
>> > have completed and no longer be around.
>> >
>> > If you are blocking on the request thread until your spawned is
> completed,
>> > could you just not use a return value from your spawned thread?
>> >
>> > bill
>> >
>> > "Mantorok" <no**@tiscali.c o.uk> wrote in message
>> > news:cu******** **@newsfeed.th. ifl.net...
>> >> Hi all
>> >>
>> >> When I start a new thread that tries to call:
>> >>
>> >> HttpContext.Cur rent.Response.R edirect()
>> >>
>> >> It fails as Current returns null, is there anyway to access the
>> >> current
>> >> httpcontext from within a new thread?
>> >>
>> >> Thanks
>> >> Kev
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 19 '05 #7
I guess I am being hard headed. Or just dumb, but I still don't see what
you are trying to accomplish.

Why don't you take you PageShower class and place it into session. Then
after the page redirects, you can pull the same object out of Session and
call another method.

Remove the Sleep method from the ShowAndWait method.

One of the rules I go with on Threading, it you can't think of a good reason
why you are using threading, then don't. If your only reason is, I thought
"it" would be better, it probably isn't.

HTH,

bill
"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
Hi bill

Well, here is a typical example of what I want to do...

public class PageShower
{
public void ShowAndWait()
{
// Redirect then wake up when required
HttpContext.Cur rent.Response.R edirect("wizard .aspx", false);

// Sleep
Sleep();
}
}

I want the redirect to happen while the class waits, it will then be
subsequently woken up later on. Ignore the other thread for now, I though
threading may be able to provide a solution on this matter.

HTH
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Response.Redire ct( newPage, false ) -- Will continue execution and just
add
the Redirect header to the outgoing request.

Response.Redire ct( newPage, true ) -- Will cause a thread abort exception and the Redirect header to the outgoing request.

Can you not place your class in Session?

I am still not sure where the spawned thread is coming in.

bill

"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
I have a class that redirects the user to a page, but I want the class to stay "alive" until the page has been posted from the user.

As you know the Response.Redire ct stops all execution, the behaviour I

want
is for the page to still post but for the execution to continue.

HTH
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:eW******** ******@TK2MSFTN GP09.phx.gbl...
>I am not exactly sure what you are wanting to do.
>
> The user makes a request to Page1.aspx.
> Page1.aspx starts ThreadA.
> ThreadA waits until Page1.aspx has been posted from the same user.
> ThreadA starts processing.
>
> bill
>
>
> "Mantorok" <no**@tiscali.c o.uk> wrote in message
> news:cu******** **@newsfeed.th. ifl.net...
>> Hi Bill
>>
>> What I basically want to do is redirect the user to an aspx, but at
>> the
>> server side I want it to wait until a response has been posted back

from
> the
>> client side before continuing execution.
>>
>> Any ideas?
>>
>> Thanks
>> Kev
>>
>> "William F. Robertson, Jr." <th****@nameht. org> wrote in message
>> news:es******** ******@tk2msftn gp13.phx.gbl...
>> > Typically when you spawn another thread, the original request thread > will
>> > have completed and no longer be around.
>> >
>> > If you are blocking on the request thread until your spawned is
> completed,
>> > could you just not use a return value from your spawned thread?
>> >
>> > bill
>> >
>> > "Mantorok" <no**@tiscali.c o.uk> wrote in message
>> > news:cu******** **@newsfeed.th. ifl.net...
>> >> Hi all
>> >>
>> >> When I start a new thread that tries to call:
>> >>
>> >> HttpContext.Cur rent.Response.R edirect()
>> >>
>> >> It fails as Current returns null, is there anyway to access the
>> >> current
>> >> httpcontext from within a new thread?
>> >>
>> >> Thanks
>> >> Kev
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 19 '05 #8
I guess I am being hard headed. Or just dumb, but I still don't see what
you are trying to accomplish.

Why don't you take you PageShower class and place it into session. Then
after the page redirects, you can pull the same object out of Session and
call another method.

Remove the Sleep method from the ShowAndWait method.

One of the rules I go with on Threading, it you can't think of a good reason
why you are using threading, then don't. If your only reason is, I thought
"it" would be better, it probably isn't.

HTH,

bill
"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
Hi bill

Well, here is a typical example of what I want to do...

public class PageShower
{
public void ShowAndWait()
{
// Redirect then wake up when required
HttpContext.Cur rent.Response.R edirect("wizard .aspx", false);

// Sleep
Sleep();
}
}

I want the redirect to happen while the class waits, it will then be
subsequently woken up later on. Ignore the other thread for now, I though
threading may be able to provide a solution on this matter.

HTH
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:%2******** ********@tk2msf tngp13.phx.gbl. ..
Response.Redire ct( newPage, false ) -- Will continue execution and just
add
the Redirect header to the outgoing request.

Response.Redire ct( newPage, true ) -- Will cause a thread abort exception and the Redirect header to the outgoing request.

Can you not place your class in Session?

I am still not sure where the spawned thread is coming in.

bill

"Mantorok" <no**@tiscali.c o.uk> wrote in message
news:cu******** **@newsfeed.th. ifl.net...
I have a class that redirects the user to a page, but I want the class to stay "alive" until the page has been posted from the user.

As you know the Response.Redire ct stops all execution, the behaviour I

want
is for the page to still post but for the execution to continue.

HTH
Kev

"William F. Robertson, Jr." <th****@nameht. org> wrote in message
news:eW******** ******@TK2MSFTN GP09.phx.gbl...
>I am not exactly sure what you are wanting to do.
>
> The user makes a request to Page1.aspx.
> Page1.aspx starts ThreadA.
> ThreadA waits until Page1.aspx has been posted from the same user.
> ThreadA starts processing.
>
> bill
>
>
> "Mantorok" <no**@tiscali.c o.uk> wrote in message
> news:cu******** **@newsfeed.th. ifl.net...
>> Hi Bill
>>
>> What I basically want to do is redirect the user to an aspx, but at
>> the
>> server side I want it to wait until a response has been posted back

from
> the
>> client side before continuing execution.
>>
>> Any ideas?
>>
>> Thanks
>> Kev
>>
>> "William F. Robertson, Jr." <th****@nameht. org> wrote in message
>> news:es******** ******@tk2msftn gp13.phx.gbl...
>> > Typically when you spawn another thread, the original request thread > will
>> > have completed and no longer be around.
>> >
>> > If you are blocking on the request thread until your spawned is
> completed,
>> > could you just not use a return value from your spawned thread?
>> >
>> > bill
>> >
>> > "Mantorok" <no**@tiscali.c o.uk> wrote in message
>> > news:cu******** **@newsfeed.th. ifl.net...
>> >> Hi all
>> >>
>> >> When I start a new thread that tries to call:
>> >>
>> >> HttpContext.Cur rent.Response.R edirect()
>> >>
>> >> It fails as Current returns null, is there anyway to access the
>> >> current
>> >> httpcontext from within a new thread?
>> >>
>> >> Thanks
>> >> Kev
>> >>
>> >>
>> >
>> >
>>
>>
>
>



Nov 19 '05 #9

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
3666
by: Kerri | last post by:
Hi, I have do some Redirects in my applitcaion. For example, when the use rhas logged in successfully I redirect them to a different page. In my Redirect all I was doing was a.. Response.Redirect("SomePage.aspx")
1
15299
by: Peter Kirk | last post by:
Hi there I have a program written by another company (it's a "web control" which returns a web-page: can I compare this to a servlet in the Java world?), which they think is causing problems on their server. But no-one really knows if this program is at fault because the problem only exhibits itself every once and a while, and the only thing they can see is that their web-users suddenly stop receiving responses.
1
2395
by: VB Programmer | last post by:
I have a default.aspx page that simply does this (in the "Try" block): Response.Redirect("MyStartPage.aspx") I keep getting this exception on this line: "System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at System.Web.HttpResponse.Redirect(String url, Boolean endResponse) at...
2
3266
by: Brian | last post by:
I'm trying to response.redirect to another page on a button click event and I get an error message stating that the thread was being aborted (if I trap for the error that is...) I've researched this a bit and see that this error is supposed to happen in response.redirect, but it's not in a Try Catch statement for me so I don't know why it won't perform the redirect When the button is clicked the page is simply reloaded with a white screen,...
3
4447
by: Robert Sorger | last post by:
I have a problem with thread execution after calling response.redirect() in a web form. Basically, I want the thread to continue to work (e.g. do some long database work) but want to redirect immediately to another page, so that the user does not have to wait. I tried the wollowing exemple with two webforms webform1.aspx and webform2.aspx : WebForm1.aspx just has one button which, when clicked, executes the following method
10
9494
by: Niggy | last post by:
I get an error - any help appreciated. System.Threading.ThreadAbortException: Thread was being aborted. at System.Threading.Thread.AbortInternal() at System.Threading.Thread.Abort(Object stateInfo) at System.Web.HttpResponse.End() at System.Web.HttpResponse.Redirect(String url, Boolean endResponse) at WebApplication1.WebForm4.DropDownList1_SelectedIndexChanged(Object sender, EventArgs e) in...
5
2024
by: Alan Silver | last post by:
Hello, I have a page that is supposed to do some checking, and if OK, set a session variable before redirecting to another page. The following code is a simplified version, I have hard-coded the basket ID and removed a load of extra checking... public partial class GoToCheckout : Page { public void Page_Load(Object o, EventArgs e) { try {
3
3057
by: Mark Huebner | last post by:
I have an aspx web page with the following C# code in the page load event. Can somebody tell me if the Response.Redirect() will cause my tLoadDNN thread to stop executing before it is finished? tLoadDNN might occasionally take up to 16 seconds to complete. protected void Page_Load(object sender, EventArgs e) { Thread tLoadDNN = new Thread(new ThreadStart(LoadDNN)); tLoadDNN.Start(); Response.Redirect("Default1.htm");
12
3462
by: =?Utf-8?B?cGI=?= | last post by:
I am having trouble doing a redirect in an async asp.net implemention. Most of the time it works, but when it doesn't it just "hangs", the browser never gets any return page. If I run it under the debugger, it works fine, though every so often I get a HttpException. System.Web.HttpException was caught ErrorCode=-2147024809 Message="An error occurred while communicating with the remote host. The error code is 0x80070057."...
0
8310
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
8732
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8503
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
1
6167
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5632
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4158
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4315
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2731
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1957
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.