Response.Redirect not working

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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 c:\inetpub\wwwroot\WebApplication1\WebForm4.aspx.vb:line 150
 
Are you Response.Redirecting inside a try/catch?

You probably need to modify your Response.Redirect to be like this

Response.Redirect("redirec.aspx", false)

The "false" tells it to wait to finish the execution of the current request
before doing the Redirect.

Hope this helps,

Chris
 
I have tried Response.Redirect("index.htm", false) and have taken the code
out of a try catch statement, but I get no response or a blank page.
 
Hmmm.

This is indeed perplexing. Can you post the method/function that you have
this code in? I'd like to try it out in my dev environment and see if I can
find something.

Chris
 
I have a DDL with Text and Value populated by a database. An example value
entry would be "../4900/Framework.doc". The code is:

Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged

Dim sumfin As String = DropDownList1.SelectedValue.ToString
Dim pos As Integer = sumfin.Length
Dim bString As String = sumfin.Substring(3, pos - 3))
Dim cString As String=http://localhost/ & bString
Response.Redirect(cString)

End Sub

Hope you can come up with an answer. Thanks.
 
Well, I'm not quite sure what's causing your Response.Redirect problem... I
took your code as a base (I had to tweak it a little bit) but it works just
fine...

Here's the tweaked code:
Private Sub DropDownList1_SelectedIndexChanged(ByVal sender As
System.Object, ByVal e As System.EventArgs) Handles
DropDownList1.SelectedIndexChanged

Dim sumfin As String = DropDownList1.SelectedValue.ToString()

Dim pos As Integer = sumfin.Length

Dim bString As String = sumfin.Substring(3, pos - 3)

Dim cString As String = "http://localhost/" & bString

Response.Redirect(cString)

End Sub
 
I've been seeing the same problem on a few of our projects, and don't know
the actual cause. I do have my suspicions that it is a cache problem in IIS.

Occasionally a page calling Repose.Redirect will just sit there with the old
URL in the location bar, and display a blank page. Sometime later it will
(usually) start to work properly. It happens intermittently. A page will
sometimes stop working for a few hours, then start working again, with no
apparent reason for stopping or starting back up.

All attempts at debugging it on the application side have failed, and I
don't really care for our people to spend time debugging into IIS to find yet
another Microsoft bug -- I'm tired of us spending developer salaries to give
MS more free bug reports.

It seems to happen more frequently (and vanish more quickly) on the SSL
production site. Also, it happens frequently when a developer changes a page
or the code behind it on the dev machines, although in that case we have a
possible reason for the problem -- and a possible cache coherency issue.

Bryan Wagstaff
Lead Programmer
 
Hi Niggy,

I got a workaround to get over this. What I did was instead of running it
from the called procedure, I created a statement in calling procedure (that
is btn1_click event). And it started working.

Raj
 
Back
Top