473,405 Members | 2,373 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,405 software developers and data experts.

How can I stop ASPX file rendering in Page_Load event?


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
Nov 19 '05 #1
6 7242
I think that exception is normal, no? Note: ThreadAbortException cannot be
caught.

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

"A.M-SG" <al******@newsgroup.nospam> wrote in message
news:Og**************@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

Nov 19 '05 #2
> 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
Nov 19 '05 #3
On Tue, 01 Nov 2005 10:50:39 -0500, 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

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.

Nov 19 '05 #4
The System.Threading.ThreadAbortException is by design..

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

use try - catch and ignore this exception ..
"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

Nov 19 '05 #5
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" <al******@newsgroup.nospam> wrote in message
news:Og**************@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

Nov 19 '05 #6
Don't bother trying to catch it. That exception type is very perculiar. You
cannot catch it at all.

Greg

"A.M-SG" <al******@newsgroup.nospam> wrote in message
news:OO**************@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" <al******@newsgroup.nospam> wrote in message
news:Og**************@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


Nov 19 '05 #7

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

Similar topics

5
by: Sue | last post by:
On code-behind page: (attributes set programatically for each of these elements) linkbutton added to tablecell textbox added to tablecell tablecells added to tablerow tablerow added to table...
3
by: Stevie_mac | last post by:
It might be me but... I dont seem to get a Page_Load event when a opening an ASPX in an iFrame. I do geta Page_Load event when an item on the ASPX (inside the iFrame) is clicked but then...
0
by: joe | last post by:
Hi, I have an aspx page that reads a session variable and loads an appropriate set of user controls. It appears that the user is going to different pages when in reality it is the same page with...
6
by: Alejandro Penate-Diaz | last post by:
Hi. I was handling key events nicely using some Javascript on my apps using something like this: this.txtUserName.Attributes.Add("onkeydown","if((event.which && event.which == 13)||(event.keyCode...
1
by: Ahmet Gunes | last post by:
Hi all, I check whether session is alive in Page_Load. If session is not alive then I want to navigate to another page, most probably the login page. But when a control, a button for...
1
by: Will Gillen | last post by:
I know this has probably been asked before, but I can't seem to find a solid answer in any of the archives. First, before my question, please forgive my limited knowledge of the event lifecycle...
13
by: Bob Jones | last post by:
Here is my situation: I have an aspx file stored in a resource file. All of the C# code is written inline via <script runat="server"tags. Let's call this page B. I also have page A that contains...
5
by: =?Utf-8?B?SmVycnkgSg==?= | last post by:
In debug mode, I want to be able to stop on the first executed line in my aspx.vb code page without setting a specific break point. Is there a way to do that? -- Jerry J
0
by: sillz | last post by:
On Apr 8, 2:00 pm, sillz <beth.sto...@gmail.comwrote: I never could get this to work. The oracle account tested fine. I ended up creating a new account in Windows with the right permissions...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
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
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,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

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.