Home All Groups Group Topic Archive Search About

How can I stop ASPX file rendering in Page_Load event?

Author
1 Nov 2005 3:50 PM
A.M-SG
Hi,

Within my code behind's Page_Load event, I need to prevent the aspx contents
be rendered.

I tried to use Response.End() , but ASP.NET gives me
"System.Threading.ThreadAbortException" exception. I also tried

Response.OutputStream.Flush();
Response.OutputStream.Close();

Or

Response.Flush();
Response.Close();

They do not stop ASP.NET to render the rest of contents.

How can I stop ASP.NET to rendering the rest of contents?

Thank you,
Alan

Author
1 Nov 2005 4:00 PM
Greg Burns
I think that exception is normal, no?  Note: ThreadAbortException cannot be
caught.

You get that also if you try and do a response.redirect.

Show quoteHide quote
"A.M-SG" <alanalan@newsgroup.nospam> wrote in message
news:OghTBwv3FHA.1188@TK2MSFTNGP12.phx.gbl...
>
> Hi,
>
> Within my code behind's Page_Load event, I need to prevent the aspx
> contents be rendered.
>
> I tried to use Response.End() , but ASP.NET gives me
> "System.Threading.ThreadAbortException" exception. I also tried
>
> Response.OutputStream.Flush();
> Response.OutputStream.Close();
>
> Or
>
> Response.Flush();
> Response.Close();
>
> They do not stop ASP.NET to render the rest of contents.
>
> How can I stop ASP.NET to rendering the rest of contents?
>
> Thank you,
> Alan
>
Are all your drivers up to date? click for free checkup

Author
1 Nov 2005 4:41 PM
Hans Kesting
Show quote Hide quote
> Hi,
>
> Within my code behind's Page_Load event, I need to prevent the aspx contents
> be rendered.
>
> I tried to use Response.End() , but ASP.NET gives me
> "System.Threading.ThreadAbortException" exception. I also tried
>
> Response.OutputStream.Flush();
> Response.OutputStream.Close();
>
> Or
>
> Response.Flush();
> Response.Close();
>
> They do not stop ASP.NET to render the rest of contents.
>
> How can I stop ASP.NET to rendering the rest of contents?
>
> Thank you,
> Alan

For a less drastic way, try to set the controls to Visible=false.
Or even "this.Visible = false;" to hide the complete control.

Hans Kesting
Author
1 Nov 2005 4:49 PM
intrader
On Tue, 01 Nov 2005 10:50:39 -0500, A.M-SG wrote:

Show quoteHide quote
>
> Hi,
>
> Within my code behind's Page_Load event, I need to prevent the aspx contents
> be rendered.
>
> I tried to use Response.End() , but ASP.NET gives me
> "System.Threading.ThreadAbortException" exception. I also tried
>
> Response.OutputStream.Flush();
> Response.OutputStream.Close();
>
> Or
>
> Response.Flush();
> Response.Close();
>
> They do not stop ASP.NET to render the rest of contents.
>
> How can I stop ASP.NET to rendering the rest of contents?
>
> Thank you,
> Alan
Explain a little more of what you are doing and why you want to stop
rendering.
If you must try overriding the Render method - don't invoke the base class
Render and don't output anything.
Author
1 Nov 2005 4:59 PM
Sreejith Ram
The System.Threading.ThreadAbortException is by design..

http://support.microsoft.com/kb/312629/EN-US/

use try - catch and ignore this exception ..


Show quoteHide quote
"A.M-SG" wrote:

>
> Hi,
>
> Within my code behind's Page_Load event, I need to prevent the aspx contents
> be rendered.
>
> I tried to use Response.End() , but ASP.NET gives me
> "System.Threading.ThreadAbortException" exception. I also tried
>
> Response.OutputStream.Flush();
> Response.OutputStream.Close();
>
> Or
>
> Response.Flush();
> Response.Close();
>
> They do not stop ASP.NET to render the rest of contents.
>
> How can I stop ASP.NET to rendering the rest of contents?
>
> Thank you,
> Alan
>
>
>
Author
1 Nov 2005 6:21 PM
A.M-SG
Thank you very much guys.

Now in know that the exception is normal and I can cach/ignore it.

this.Visible = false and also overriding Render methods also are good idea.

Thank you again,
Alan


Show quoteHide quote
"A.M-SG" <alanalan@newsgroup.nospam> wrote in message
news:OghTBwv3FHA.1188@TK2MSFTNGP12.phx.gbl...
>
> Hi,
>
> Within my code behind's Page_Load event, I need to prevent the aspx
> contents be rendered.
>
> I tried to use Response.End() , but ASP.NET gives me
> "System.Threading.ThreadAbortException" exception. I also tried
>
> Response.OutputStream.Flush();
> Response.OutputStream.Close();
>
> Or
>
> Response.Flush();
> Response.Close();
>
> They do not stop ASP.NET to render the rest of contents.
>
> How can I stop ASP.NET to rendering the rest of contents?
>
> Thank you,
> Alan
>
Author
1 Nov 2005 6:27 PM
Greg Burns
Don't bother trying to catch it.  That exception type is very perculiar. You
cannot catch it at all.

Greg

Show quoteHide quote
"A.M-SG" <alanalan@newsgroup.nospam> wrote in message
news:OOx0EEx3FHA.1596@tk2msftngp13.phx.gbl...
> Thank you very much guys.
>
> Now in know that the exception is normal and I can cach/ignore it.
>
> this.Visible = false and also overriding Render methods also are good
> idea.
>
> Thank you again,
> Alan
>
>
> "A.M-SG" <alanalan@newsgroup.nospam> wrote in message
> news:OghTBwv3FHA.1188@TK2MSFTNGP12.phx.gbl...
>>
>> Hi,
>>
>> Within my code behind's Page_Load event, I need to prevent the aspx
>> contents be rendered.
>>
>> I tried to use Response.End() , but ASP.NET gives me
>> "System.Threading.ThreadAbortException" exception. I also tried
>>
>> Response.OutputStream.Flush();
>> Response.OutputStream.Close();
>>
>> Or
>>
>> Response.Flush();
>> Response.Close();
>>
>> They do not stop ASP.NET to render the rest of contents.
>>
>> How can I stop ASP.NET to rendering the rest of contents?
>>
>> Thank you,
>> Alan
>>
>
>

Bookmark and Share