<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="http://forums.asp.net/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Web Forms</title><link>http://forums.asp.net/18.aspx</link><description>All about building ASP.NET Pages - server controls, events, validation, etc.</description><dc:language>en</dc:language><generator>CommunityServer 2007 SP1 (Build: 20510.895)</generator><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1547412.aspx</link><pubDate>Thu, 25 Jan 2007 01:02:15 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1547412</guid><dc:creator>mbanavige</dc:creator><author>mbanavige</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1547412.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1547412</wfw:commentRss><description>&lt;p&gt;Line 2 will not execute.&lt;/p&gt;
&lt;p&gt;since you did not use the overload for Redirect, the thread aborts as soon as the redirect is called.&amp;nbsp; The only way to reach line 2 is to code it like this:&lt;/p&gt;&lt;pre class=coloredcode&gt;&lt;b id=1&gt;1    &lt;/b&gt;Response.Redirect(Page.ResolveUrl(&lt;span class=st&gt;"theWebPage.aspx"&lt;/span&gt;), &lt;span class=kwd&gt;False&lt;/span&gt;)
&lt;b id=2&gt;2    &lt;/b&gt;Response.&lt;span class=kwd&gt;End&lt;/span&gt;()
&lt;b id=3&gt;    &lt;/b&gt;
&lt;/pre&gt;&amp;nbsp;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1546515.aspx</link><pubDate>Wed, 24 Jan 2007 15:17:13 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1546515</guid><dc:creator>brgdotnet</dc:creator><author>brgdotnet</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1546515.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1546515</wfw:commentRss><description>&lt;p&gt;Thank you for the help. What you say makes perfect sense. And you have made things clearer to me. I need to mentally put a few more pieces of the puzzle together before I understand completely. So I need to ask one or more questions to completely understand this.&lt;/p&gt;
&lt;p&gt;Hm.. Ok here is my question.&lt;/p&gt;
&lt;p&gt;1.) For the following block of code, will line 2 ever be executed? If so, what would ever cause program execution to return to line 2. &lt;/p&gt;
&lt;p&gt;1&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.Redirect(Page.ResolveUrl(&lt;span class=st&gt;&lt;font color=#ff0000&gt;"&lt;/font&gt;&lt;/span&gt;theWebPage.aspx"));&lt;br /&gt;2&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Response.End();&lt;/p&gt;
&lt;p&gt;It seems that the thread of execution at line 1 will end when program execution is transfered to "theWebPage.aspx". So I can't see where code execution will ever return to line 2. Is that the case?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533828.aspx</link><pubDate>Tue, 16 Jan 2007 04:09:24 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533828</guid><dc:creator>mbanavige</dc:creator><author>mbanavige</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533828.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533828</wfw:commentRss><description>&lt;p&gt;since your pondering this one - here's something else to ponder over: &lt;a href="http://www.c6software.com/codesolutions/dotnet/threadabortexception.aspx"&gt;http://www.c6software.com/codesolutions/dotnet/threadabortexception.aspx&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;happy reading :-)&lt;/p&gt;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533809.aspx</link><pubDate>Tue, 16 Jan 2007 03:45:02 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533809</guid><dc:creator>Snowst</dc:creator><author>Snowst</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533809.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533809</wfw:commentRss><description>hmm thanks for the drawback considerations, I guess for efficiency and avoiding false exceptions I'll probably have to stick will all of those annoying empty catch statements except for in rare cases. Too bad there's not a way to end a thread without generating this exception, it's a very common annoyance. Most people who call&amp;nbsp;Redirect() would expect for the current thread to abort and not consider it an exception when doing so.</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533778.aspx</link><pubDate>Tue, 16 Jan 2007 03:18:22 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533778</guid><dc:creator>mbanavige</dc:creator><author>mbanavige</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533778.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533778</wfw:commentRss><description>&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;Snowst:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt; 
&lt;p&gt;now I can get rid of all of my empty ThreadAbortException Catch Statements!&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;/div&gt;&lt;/blockquote&gt;
&lt;p&gt;There are 2 side effects to be aware of though which you should consider before making that change.&lt;/p&gt;
&lt;p&gt;1) the page code (full lifecycle) will continue to run consuming system resources.&amp;nbsp; Imagine how much unnecessary code might run&amp;nbsp;if the redirect occurred in page_load.&lt;/p&gt;
&lt;p&gt;2) after the redirect, its possible that you have some logic (logging perhaps or something...)&amp;nbsp;that would be innapropriate to run if the page wasnt actually sent to the client browser.&lt;/p&gt;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533761.aspx</link><pubDate>Tue, 16 Jan 2007 03:05:50 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533761</guid><dc:creator>Snowst</dc:creator><author>Snowst</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533761.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533761</wfw:commentRss><description>&lt;p&gt;&lt;blockquote&gt;&lt;div&gt;&lt;img src="http://forums.asp.net/Themes/default/images/icon-quote.gif" /&gt; &lt;strong&gt;KaziManzurRashid:&lt;/strong&gt;&lt;/div&gt;&lt;div&gt;To avoid the ThreadAbortException use the overloaded method. Response.Redirect("Target.aspx", true);&lt;/div&gt;&lt;/blockquote&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;As explained by &lt;a href="http://forums.asp.net/members/mbanavige.aspx"&gt;mbanavige&lt;/a&gt;, in order to avoid the ThreadAbortException you would actually call the overloaded constructor but with a value of false, not true. Where a false tells the Response.Redirect method to not abort the thread (in other words not call Response.End() which is what really is responsible for this exception) This works great, now I can get rid of all of my empty ThreadAbortException Catch Statements!&lt;/p&gt;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533676.aspx</link><pubDate>Tue, 16 Jan 2007 01:57:09 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533676</guid><dc:creator>mbanavige</dc:creator><author>mbanavige</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533676.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533676</wfw:commentRss><description>&lt;p&gt;The default behavior of Response.Redirect is to send the redirect to the client&amp;nbsp;and end the response which aborts the thread.&amp;nbsp; &lt;br /&gt;in&amp;nbsp; this example, Response.End will not get called since the thread will automatically abort on the redirect.&lt;/p&gt;&lt;pre class=coloredcode&gt;Response.Redirect(Page.ResolveUrl(&lt;span class=st&gt;"~/"&lt;/span&gt; + theWebPage));
Response.End(); &lt;/pre&gt;
&lt;p&gt;This behavior can be changed though by using the Redirect overload to instruct that method not to automatically end the response.&lt;/p&gt;&lt;pre class=coloredcode&gt;&amp;nbsp;
&lt;pre class=coloredcode&gt;Response.Redirect(&lt;span class=st&gt;"somePage.aspx"&lt;/span&gt;, &lt;span class=kwd&gt;False&lt;/span&gt;) &lt;span class=cmt&gt;'dont end the response just yet
'now do a little more work
'...
&lt;/span&gt;Response.&lt;span class=kwd&gt;End&lt;/span&gt;() &lt;span class=cmt&gt;'now end the response without completing the rest of the page lifecycle
&lt;/span&gt;&lt;/pre&gt;&amp;nbsp;&amp;nbsp;&lt;/pre&gt;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533675.aspx</link><pubDate>Tue, 16 Jan 2007 01:56:01 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533675</guid><dc:creator>satish_nagdev</dc:creator><author>satish_nagdev</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533675.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533675</wfw:commentRss><description>&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;could you tell what error you are getting?&lt;/p&gt;
&lt;p&gt;just comment response.end() and try.&lt;/p&gt;
&lt;p&gt;thanks,&lt;/p&gt;
&lt;p&gt;satish.&lt;/p&gt;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533665.aspx</link><pubDate>Tue, 16 Jan 2007 01:41:38 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533665</guid><dc:creator>Jessica Cao - MSFT</dc:creator><author>Jessica Cao - MSFT</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533665.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533665</wfw:commentRss><description>&lt;p&gt;hi,&lt;/p&gt;
&lt;p&gt;Response.End()' s behavior has some new behavior in asp.net2.0&lt;/p&gt;
&lt;p&gt;for more information &lt;/p&gt;
&lt;p&gt;refer to this thread&lt;/p&gt;
&lt;p&gt;&lt;a href="http://west-wind.com/WebLog/posts/3417.aspx"&gt;http://west-wind.com/WebLog/posts/3417.aspx&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533552.aspx</link><pubDate>Mon, 15 Jan 2007 23:55:08 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533552</guid><dc:creator>KaziManzurRashid</dc:creator><author>KaziManzurRashid</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533552.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533552</wfw:commentRss><description>To avoid the ThreadAbortException use the overloaded method. Response.Redirect("Target.aspx", true);</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533275.aspx</link><pubDate>Mon, 15 Jan 2007 19:55:31 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533275</guid><dc:creator>webdevl</dc:creator><author>webdevl</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533275.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533275</wfw:commentRss><description>&lt;p&gt;Response.Redirect sends a 302 response header to the browser telling the browser the object has moved.&amp;nbsp; Response.End ends the page execution.&amp;nbsp; The thing is that Response.End is called internally by Response.Redirect so there is no need to call it seperately, in fact it will cause an error.&amp;nbsp; Here are a couple articles that might shed more light on this.&lt;/p&gt;
&lt;p&gt;&lt;a href="http://support.microsoft.com/kb/312629"&gt;http://support.microsoft.com/kb/312629&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="http://haacked.com/archive/2004/10/06/1308.aspx"&gt;http://haacked.com/archive/2004/10/06/1308.aspx&lt;/a&gt;&lt;/p&gt;</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533260.aspx</link><pubDate>Mon, 15 Jan 2007 19:48:58 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533260</guid><dc:creator>Snowst</dc:creator><author>Snowst</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533260.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533260</wfw:commentRss><description>Ok, I couldn't avoid doing the test for my own knowledge, the answer is that Response.End(); is never getting called because the actual Response.Redirect is the one the method thats throwing the exception. So whether you are using at try catch or not, the Response.End(); is never getting called and unnecessary.</description></item><item><title>Re: Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533241.aspx</link><pubDate>Mon, 15 Jan 2007 19:33:32 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533241</guid><dc:creator>Snowst</dc:creator><author>Snowst</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533241.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533241</wfw:commentRss><description>My guess without doing the actual test would be that maybe they are trying to avoid the &amp;nbsp;&lt;pre class=coloredcode&gt; ThreadAbortException &lt;/pre&gt;&amp;nbsp;This exception normally gets thrown when you redirect to another page. Is it inside of a try, catch loop? Just a guess, not 100% on whether this avoids the exception though. Anyone know for sure?</description></item><item><title>Purpose of the Response.End(); method ?</title><link>http://forums.asp.net/thread/1533233.aspx</link><pubDate>Mon, 15 Jan 2007 19:25:01 GMT</pubDate><guid isPermaLink="false">4c671506-2930-414c-a40b-8bf57ded5924:1533233</guid><dc:creator>brgdotnet</dc:creator><author>brgdotnet</author><slash:comments>0</slash:comments><comments>http://forums.asp.net/thread/1533233.aspx</comments><wfw:commentRss>http://forums.asp.net/commentrss.aspx?SectionID=18&amp;PostID=1533233</wfw:commentRss><description>&lt;p&gt;What is the purpose of the Response.End() method? Is it necessary to call Response.End() after doing a Response.Redirect() ?&lt;/p&gt;
&lt;p&gt;I am maintaining some C# code. I see that they use the &lt;font size=2&gt;Response.Redirect() method to transfer control to a different web page. Shortly after the Response.Redirect in the code, the Response.End() method is called. I don't know&amp;nbsp;why though?&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Example:&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Response.Redirect(Page.ResolveUrl(&lt;font color=#800000 size=2&gt;"~/"&lt;/font&gt;&lt;font size=2&gt; +&lt;/font&gt;&lt;font size=2&gt; theWebPage));&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;Response.End(); &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;font size=2&gt;&amp;nbsp;&lt;/font&gt;&lt;/p&gt;</description></item></channel></rss>