473,382 Members | 1,359 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,382 software developers and data experts.

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 1448
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: anonieko | last post by:
> > > > Writing an XML document the .Net way If you've been using the .Net Framework for even a week, you know that the kids in Redmond really thought of almost everything, so they're not...
13
by: Stumped and Confused | last post by:
Hello, I really, really, need some help here - I've spent hours trying to find a solution. In a nutshell, I'm trying to have a user input a value in form's textfield. The value should then be...
4
by: etropic | last post by:
Im confused I want an .aspx page to have a table with my data in it. At first I wrote FillTablew(); in my Page_Load even in the Code Behind file. I had it loop the db etc. and use Response.Write...
5
by: localhost | last post by:
I have a complex ASPX page, and in the code-behind I instance an object that inherits from Class. Upon instantiation, I want the object to write some JavaScript code at the end of the HEAD tag,...
2
by: Steve Franks | last post by:
What is the proper/best way to dynamically change the HTML written out to the browser based on the value from a variable in a code behind page? For instance, I have test.aspx.vb as a code behind...
7
by: samuelberthelot | last post by:
Hi, I have the following in my asp page: <% response.write(Header) %> where Header contains HTML markup such ass <html> <body> .... I must write the code in the aspx file and not in the...
10
by: Ron | last post by:
Hi, I currently am generating a report by to my end user by retrieving data from my back end DB and concatenating strings together and place this string concatenation within a Label control. I...
23
by: asit dhal | last post by:
hello friends, can anyone explain me how to use read() write() function in C. and also how to read a file from disk and show it on the monitor using onlu read(), write() function ??????
6
by: jojoba | last post by:
hi everyone! i'm serving up an asp.net page using ajax futures. long story short: i have two update panels. one has a webpage in it (e.g. www.google.com). the other has an image inside of a...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

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.