473,406 Members | 2,467 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Response.Redirect generates Exception

Vi
Hi,
I have an <asp:Button> control on a page. When it is clicked, I run a db
stored procedure and then I want to go to the next page by executing a
Response.Redirect("NextPage.aspx?id=" + myID).
The Response.Redirect always generates an Exception "Thread was being
aborted."
Is there a way to execute Response.Redirect without generating this
exception? (I cannot use Server.Transfer is this particular case).
Or can I achieve the same functionality (execute a stored proc and go to
another page) in a different way?

Thanks.
Nov 19 '05 #1
4 5861
http://support.microsoft.com/default...b;en-us;312629

HTH
----------------
Dave Fancher
http://www.davefancher.com

"Vi" <Vi@discussions.microsoft.com> wrote in message
news:0E**********************************@microsof t.com...
Hi,
I have an <asp:Button> control on a page. When it is clicked, I run a db
stored procedure and then I want to go to the next page by executing a
Response.Redirect("NextPage.aspx?id=" + myID).
The Response.Redirect always generates an Exception "Thread was being
aborted."
Is there a way to execute Response.Redirect without generating this
exception? (I cannot use Server.Transfer is this particular case).
Or can I achieve the same functionality (execute a stored proc and go to
another page) in a different way?

Thanks.

Nov 19 '05 #2
in fact

response.redirect(url, false)

is nearly always recommended
as how does the method that calls response.redirect(url, true)
have any way of knowing there is nothing else important going
to happen next?

in classic asp it was common to emulate this

by using a RedirectURL variable as follows:

Dim RedirectURL
Start() 'calls main page processing
If Len(RedirectURL) > 0 Then
Response.Redirect RedirectURL
End If

this made sure that important code wasn't skipped
for instance you would wrap all your asp pages
in a common library function to enable uniform
code processing of say logging utilities and custom
session handling code and all sorts of good things

Nov 19 '05 #3
Hi,

The exception is thrown because thread is being terminated, which is the
most logical way to end the response. Always use try - catch statement when
calling End, Redirect and Transfer methods. John - again - this newsgroup is
not about classic ASP :)

AND STOP MAKING STUPID POSTS AND ANSWERS :)
--
Milosz Skalecki
MCP, MCAD
"John Rivers" wrote:
in fact

response.redirect(url, false)

is nearly always recommended
as how does the method that calls response.redirect(url, true)
have any way of knowing there is nothing else important going
to happen next?

in classic asp it was common to emulate this

by using a RedirectURL variable as follows:

Dim RedirectURL
Start() 'calls main page processing
If Len(RedirectURL) > 0 Then
Response.Redirect RedirectURL
End If

this made sure that important code wasn't skipped
for instance you would wrap all your asp pages
in a common library function to enable uniform
code processing of say logging utilities and custom
session handling code and all sorts of good things

Nov 19 '05 #4

I must protest.

There is nothing stupid about my answer.

My reference to Classic ASP was to highlight the fact that
a shortcoming of cASP was a Response.Redirect method that
stopped code dead, and that this has been fixed in ASP.NET
with the Response.Redirect(url, false) overload.

If you don't agree with my comment please feel free to write
to microsoft and ask them to remove that feature.

If you can't see the danger in allowing threads to be suddenly
terminated, instead of code running to a natural end and then
redirecting, I recommend you ask someone else, whose
opinion you do value, to explain it to you.

Until then I look forward to watching one of your connections
with an open transaction getting returned to the pool or
a serviced component exiting before disposal and watching
your panicky face as you realise ...

Please see:

http://en.wikipedia.org/wiki/Nincompoop

for further guidance.

Nov 19 '05 #5

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

Similar topics

2
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.. ...
1
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...
1
by: EagleRed | last post by:
I am writing an ASP.NET application in which I am using the Response.Redirect() call. I noticed that I catch a ThreadAbort Exception after making the call. Indeed the documentation states that this...
1
by: Henry | last post by:
Hello, I have a question about ASP.NET process. In this case: Try 'SOME CODE Response.Redirect("some_asp_page.aspx") Catch obj_Exception as Exception Throw obj_Exception
1
by: Vi | last post by:
Hi, I have a try block in which I execute a Page.Response.Redirect("myPage.aspx"); This statement always generates the exception: "Thread was being aborted" and the execution continues in the...
1
by: MikeM | last post by:
We are getting a behavior on a Response.Redirect("SomeUrl", True) that I'm hoping someone can explain. This all refers to the code snip at the end. By the way, this is all VB ASP.NET v1.0 code. ...
1
by: Eric | last post by:
I have the following situation: I was getting intermittent errors using Reponse.Redirct("url", true) and was trying to catch the ThreadAbortException, but it was not staying caught and was showing...
5
by: venner | last post by:
I'm having an issue with an ASP.NET website after upgrading to ASP.NET 2.0. The website makes use of a central authentication service (CAS) provided at the university I work for. Each page checks...
3
by: jasonheath.net | last post by:
I apologize in advance for the length of this post. I wanted to get as much detail as possible in here. We have 1 web app that contains the functionality to do some single sign-on logic. The...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
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...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

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.