Response.redirect not working

D

Doug

In the code below, I am trying to go from one asp page to another:

For Each tripToAccept As String In tripsToAccept.Split("/"c)
dataManager.UpdateTripDetail("Accept", CInt(tripToAccept),
Hiduser.Value)
Next


Response.Redirect("TripAcceptReject.aspx", False)


I am not getting an error, but I'm also not seeing anything happen at
all. This is an existing app and it looks like the page I'm trying to
open up is a modal page, could that be an issue. Is there another way
to open up one asp page from another?
 
N

nateastle

In the code below, I am trying to go from one asp page to another:

For Each tripToAccept As String In tripsToAccept.Split("/"c)
dataManager.UpdateTripDetail("Accept", CInt(tripToAccept),
Hiduser.Value)
Next

Response.Redirect("TripAcceptReject.aspx", False)

I am not getting an error, but I'm also not seeing anything happen at
all. This is an existing app and it looks like the page I'm trying to
open up is a modal page, could that be an issue. Is there another way
to open up one asp page from another?

Is the previous code getting excuted or is the redirect not working?
You can try Server.transfer(urllocation)
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Doug said:
In the code below, I am trying to go from one asp page to another:

For Each tripToAccept As String In tripsToAccept.Split("/"c)
dataManager.UpdateTripDetail("Accept", CInt(tripToAccept),
Hiduser.Value)
Next


Response.Redirect("TripAcceptReject.aspx", False)


I am not getting an error, but I'm also not seeing anything happen at
all. This is an existing app and it looks like the page I'm trying to
open up is a modal page, could that be an issue. Is there another way
to open up one asp page from another?

As you are setting the second parameter to false, the execution
continues in the code. Obviously you are doing something else later on
in the code that prevents the redirection.

If you want the execution of the current code to end after the Redirect
statement, specify true as the second parameter, or use the overload
without a second parameter:

Response.Redirect("TripAcceptReject.aspx")
 
D

Doug

As you are setting the second parameter to false, the execution
continues in the code. Obviously you are doing something else later on
in the code that prevents the redirection.

I'm not doing anything later on. There's no more code after this.
It should go directly to the TripAcceptReject page, but it doesn't.
If you want the execution of the current code to end after the Redirect
statement, specify true as the second parameter, or use the overload
without a second parameter:

I tried that, but I kept getting a threading error. Per a previous
post, someone told me to use false for that parameter to avoid the
error and then this is what happens.

I did try using Server.Transfer and that appears to work but after it
executes the code in the redirected page, it jumps back to the calling
page, throws that Threading exception, but still displays the
TripAcceptReject page, but within the same window. I want it to
display as a seperate window (I believe it currently is doing this as
a modal window, but the way it was called before is through
Javascript, I'm now in server side code (VB) and need to do it there.
I can't believe that it is that hard to do a simple redirect to a
window!!!! :))
 
?

=?ISO-8859-1?Q?G=F6ran_Andersson?=

Doug said:
I'm not doing anything later on. There's no more code after this.
It should go directly to the TripAcceptReject page, but it doesn't.

There doesn't have to be any code that you have written after that to
interfer with the process. The page creation process continues,
rendering the controls that you have in the page into an html page that
is sent to the browser.

If you don't want that to happen, you have to make sure that there are
no controls in the page so that the rendering doesn't produce any
output. Then it might work.
I tried that, but I kept getting a threading error. Per a previous
post, someone told me to use false for that parameter to avoid the
error and then this is what happens.

The Response.Redirect method uses an exception to end the execution of
the current page. This is normal, and if you want it to work normally,
you should not catch this exception.

Using the second parameter does prevent the exception to be thrown, but
if you want to do it that way, you have to deal with the rest of the
page creation process.
I did try using Server.Transfer and that appears to work but after it
executes the code in the redirected page, it jumps back to the calling
page, throws that Threading exception, but still displays the
TripAcceptReject page, but within the same window.

It's not jumping back to the page. It's rendering the page because the
first page added it's controls to the page tree, and the second page
also added it's controls to the page tree, and is rendering all of it
into a single html page.
I want it to
display as a seperate window (I believe it currently is doing this as
a modal window, but the way it was called before is through
Javascript, I'm now in server side code (VB) and need to do it there.
I can't believe that it is that hard to do a simple redirect to a
window!!!! :))

If you want to display it as a separate window, you can't use server
code to accomplish it. A new window can only be opened from the browser,
so you have to either use a link with target="_blank" or the window.open
method in Javascript.
 
D

Doug

If you want to display it as a separate window, you can't use server
code to accomplish it. A new window can only be opened from the browser,
so you have to either use a link with target="_blank" or the window.open
method in Javascript.

I am not sure how to go from being in server code to calling
Javascript code. Do you have some suggestions for where to look to
learn how to do this?
 

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

Top