469,642 Members | 1,221 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,642 developers. It's quick & easy.

Write entire page from code behind

Hi;

I have a page where the file.aspx.cs Page_Load() method writes the entire
contents out directly. I use this to write a pdf or rtf file as the web page
to display.

In .net 1.1 the way I did this was:
Response.ContentType = contentType;
Response.BinaryWrite(((MemoryStream)proc.GetReport ()).ToArray());
Response.End();
return;

This does display the page, but the call to Response.End() throws a
ThreadAbortException. What am I doing wrong?

--
thanks - dave
Dec 15 '05 #1
4 1339
nothing. Response.End() works by aborting the current thread, to stop
furthor processimng. don't catch this error.

-- bruce (sqlwork.com)

"David Thielen" <th*****@nospam.nospam> wrote in message
news:7B**********************************@microsof t.com...
Hi;

I have a page where the file.aspx.cs Page_Load() method writes the entire
contents out directly. I use this to write a pdf or rtf file as the web
page
to display.

In .net 1.1 the way I did this was:
Response.ContentType = contentType;
Response.BinaryWrite(((MemoryStream)proc.GetReport ()).ToArray());
Response.End();
return;

This does display the page, but the call to Response.End() throws a
ThreadAbortException. What am I doing wrong?

--
thanks - dave

Dec 15 '05 #2
Hi;

Is there a way to do this without an exception? I really dislike exceptions
in the happy path.

--
thanks - dave
"Bruce Barker" wrote:
nothing. Response.End() works by aborting the current thread, to stop
furthor processimng. don't catch this error.

-- bruce (sqlwork.com)

"David Thielen" <th*****@nospam.nospam> wrote in message
news:7B**********************************@microsof t.com...
Hi;

I have a page where the file.aspx.cs Page_Load() method writes the entire
contents out directly. I use this to write a pdf or rtf file as the web
page
to display.

In .net 1.1 the way I did this was:
Response.ContentType = contentType;
Response.BinaryWrite(((MemoryStream)proc.GetReport ()).ToArray());
Response.End();
return;

This does display the page, but the call to Response.End() throws a
ThreadAbortException. What am I doing wrong?

--
thanks - dave


Dec 15 '05 #3
Hi;

If I make it the last line of code in my method, then no exception. Is that
by design? And if so, that's the solution.

--
thanks - dave
"Bruce Barker" wrote:
nothing. Response.End() works by aborting the current thread, to stop
furthor processimng. don't catch this error.

-- bruce (sqlwork.com)

"David Thielen" <th*****@nospam.nospam> wrote in message
news:7B**********************************@microsof t.com...
Hi;

I have a page where the file.aspx.cs Page_Load() method writes the entire
contents out directly. I use this to write a pdf or rtf file as the web
page
to display.

In .net 1.1 the way I did this was:
Response.ContentType = contentType;
Response.BinaryWrite(((MemoryStream)proc.GetReport ()).ToArray());
Response.End();
return;

This does display the page, but the call to Response.End() throws a
ThreadAbortException. What am I doing wrong?

--
thanks - dave


Dec 15 '05 #4
Hey Dave,

Bruce is right , there is no problem here. Just a by design behavior
because manually end asp.net response need to abort the current working
thread... Just not catch this exception or if you've used try-catch ..
block, ignore it....

thanks,

Steven Cheng
Microsoft Online Support

Get Secure! www.microsoft.com/security
(This posting is provided "AS IS", with no warranties, and confers no
rights.)
--------------------
| Thread-Topic: Write entire page from code behind
| thread-index: AcYBFaxmJzKPFxOZT0KhA0PS384ikQ==
| X-WBNR-Posting-Host: 199.45.247.98
| From: "=?Utf-8?B?RGF2aWQgVGhpZWxlbg==?=" <th*****@nospam.nospam>
| References: <7B**********************************@microsoft.co m>
<ed**************@TK2MSFTNGP15.phx.gbl>
| Subject: Re: Write entire page from code behind
| Date: Wed, 14 Dec 2005 17:20:02 -0800
| Lines: 39
| Message-ID: <F9**********************************@microsoft.co m>
| MIME-Version: 1.0
| Content-Type: text/plain;
| charset="Utf-8"
| Content-Transfer-Encoding: 7bit
| X-Newsreader: Microsoft CDO for Windows 2000
| Content-Class: urn:content-classes:message
| Importance: normal
| Priority: normal
| X-MimeOLE: Produced By Microsoft MimeOLE V6.00.3790.0
| Newsgroups: microsoft.public.dotnet.framework.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.phx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.phx.gbl!TK2MSFTNGXA01.phx.gbl!TK2MSF TNGXA03.phx.gbl
| Xref: TK2MSFTNGXA02.phx.gbl
microsoft.public.dotnet.framework.aspnet:364979
| X-Tomcat-NG: microsoft.public.dotnet.framework.aspnet
|
| Hi;
|
| If I make it the last line of code in my method, then no exception. Is
that
| by design? And if so, that's the solution.
|
| --
| thanks - dave
|
|
| "Bruce Barker" wrote:
|
| > nothing. Response.End() works by aborting the current thread, to stop
| > furthor processimng. don't catch this error.
| >
| > -- bruce (sqlwork.com)
| >
| > "David Thielen" <th*****@nospam.nospam> wrote in message
| > news:7B**********************************@microsof t.com...
| > > Hi;
| > >
| > > I have a page where the file.aspx.cs Page_Load() method writes the
entire
| > > contents out directly. I use this to write a pdf or rtf file as the
web
| > > page
| > > to display.
| > >
| > > In .net 1.1 the way I did this was:
| > > Response.ContentType = contentType;
| > > Response.BinaryWrite(((MemoryStream)proc.GetReport ()).ToArray());
| > > Response.End();
| > > return;
| > >
| > > This does display the page, but the call to Response.End() throws a
| > > ThreadAbortException. What am I doing wrong?
| > >
| > > --
| > > thanks - dave
| >
| >
| >
|

Dec 15 '05 #5

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

reply views Thread by anonieko | last post: by
13 posts views Thread by Stumped and Confused | last post: by
5 posts views Thread by localhost | last post: by
7 posts views Thread by samuelberthelot | last post: by
10 posts views Thread by Ron | last post: by
23 posts views Thread by asit dhal | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.