473,695 Members | 1,867 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Conten tType = contentType;
Response.Binary Write(((MemoryS tream)proc.GetR eport()).ToArra y());
Response.End();
return;

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

--
thanks - dave
Dec 15 '05 #1
4 1463
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******** *************** ***********@mic rosoft.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.Conten tType = contentType;
Response.Binary Write(((MemoryS tream)proc.GetR eport()).ToArra y());
Response.End();
return;

This does display the page, but the call to Response.End() throws a
ThreadAbortExce ption. 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******** *************** ***********@mic rosoft.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.Conten tType = contentType;
Response.Binary Write(((MemoryS tream)proc.GetR eport()).ToArra y());
Response.End();
return;

This does display the page, but the call to Response.End() throws a
ThreadAbortExce ption. 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******** *************** ***********@mic rosoft.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.Conten tType = contentType;
Response.Binary Write(((MemoryS tream)proc.GetR eport()).ToArra y());
Response.End();
return;

This does display the page, but the call to Response.End() throws a
ThreadAbortExce ption. 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: AcYBFaxmJzKPFxO ZT0KhA0PS384ikQ ==
| X-WBNR-Posting-Host: 199.45.247.98
| From: "=?Utf-8?B?RGF2aWQgVGh pZWxlbg==?=" <th*****@nospam .nospam>
| References: <7B************ *************** *******@microso ft.com>
<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************ *************** *******@microso ft.com>
| 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.publi c.dotnet.framew ork.aspnet
| NNTP-Posting-Host: TK2MSFTNGXA03.p hx.gbl 10.40.2.250
| Path: TK2MSFTNGXA02.p hx.gbl!TK2MSFTN GXA01.phx.gbl!T K2MSFTNGXA03.ph x.gbl
| Xref: TK2MSFTNGXA02.p hx.gbl
microsoft.publi c.dotnet.framew ork.aspnet:3649 79
| X-Tomcat-NG: microsoft.publi c.dotnet.framew ork.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******** *************** ***********@mic rosoft.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.Conten tType = contentType;
| > > Response.Binary Write(((MemoryS tream)proc.GetR eport()).ToArra y());
| > > Response.End();
| > > return;
| > >
| > > This does display the page, but the call to Response.End() throws a
| > > ThreadAbortExce ption. 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
1813
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 going to make you concatenate huge strings to build an XML document. For our example, we're going to create a new page on our site called
13
9620
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 assigned to a variable and output using document.write. (Note, there is no submit button or other form elements. Basically
4
2638
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 of a bunch of strings. This works great as long as all I want is the results of those Response.Writes I believe what I REALLY want is to convert those Response.Writes to a str cat in the code behind, and then in the body of my .aspx page to do...
5
1468
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, immediately before BODY begins. How can I do that? Thanks.
2
2507
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 page. In this code behind's Page_Load event which sets a boolean called useAlternateStyle to true or false based on business logic. Now from my main page (test.aspx) I want to either write out HTML that sets the style sheet to "mainStyle.css"...
7
2711
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 code behind so that the markup are generated at correct places in html stream.
10
1904
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 am finding some efficiencies issues and would like to use Response.Write() and stream this information directly to the aspx page. All of my code is in the code behind and i would like to keep it there.
23
2991
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
8795
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 div. however, when i update the div in code behind ( via UpdatePanel_div.Update() ), the entire page refreshes. if i change the div to an iframe, then the entire page does not
0
8565
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
9113
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8977
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8839
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8822
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
5837
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4339
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
2269
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
1971
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.