473,602 Members | 2,774 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

need clarity -- Response.Clear, .ClearHeaders, .Buffer

hello,

so from time to time i have to write code to send a file or a stream
back to the end user. in my mini library i have code to do so. however,
some of the Response object properties arent exactly clear to me, and
for some reason they arent spec'd out in my v1.1 SDK.

can anyone provide a simple break down of the intended purpose &
appropiateness of these:

Response.Clear( )
Response.ClearH eaders()
Response.Buffer

....thanks!

matt

Nov 21 '06 #1
4 6745
Matt,
If you read the MSDN Documentation on the HttpResponse class, you'll find
all these methods clearly spelled out:

http://msdn2.microsoft.com/en-gb/lib...presponse.aspx

Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ma**@mailinato r.com" wrote:
hello,

so from time to time i have to write code to send a file or a stream
back to the end user. in my mini library i have code to do so. however,
some of the Response object properties arent exactly clear to me, and
for some reason they arent spec'd out in my v1.1 SDK.

can anyone provide a simple break down of the intended purpose &
appropiateness of these:

Response.Clear( )
Response.ClearH eaders()
Response.Buffer

....thanks!

matt

Nov 21 '06 #2
Peter wrote:
Matt,
If you read the MSDN Documentation on the HttpResponse class, you'll find
all these methods clearly spelled out:
thanks.

but if MSDN made everything clear, id be expert on everything ive read
there, and nobody would buy books :)

while those are useful technical explainations of what each method
does, i dont know that i would say they clearly spell things out... for
example, when reading the "HttpResponse.C lear Method" entry, it says:

Remarks
The Clear method does not clear header information.

yet, in the code sample it says:

// Set the page's content type to JPEG files
// and clear all response headers.
Response.Conten tType = "image/jpeg";
Response.Clear( );

....which seem contradictory to me (does it clear headers, or doesnt it?
but more importantly -- *why* do i want to clear headers!?)

so i guess what im looking for is more of a "Well, the basic idea of X
is xxxx. You really only need to use X when doing Y..." type
discussion.

for instance, im going to send the user an .XLS -- why is it important
to clear the response headers (.ClearHeaders) from my event handler's
routine? or to use .Clear? omitting the lines seems to make no
difference in my test environment.

or, when is it to the developer's advantage to enable output buffering
on the response?
....so can anyone comment on these HttpResponse items in more of a
non-tech-specs, general-rules-of-thumb fashion?
thanks!
matt

Nov 21 '06 #3
Yep. I read this as you saying "I think I really need to study the HTTP
Protocol first". That will help, plenty of free tutorials on the web that
will explain what headers are, etc.
Peter

--
Co-founder, Eggheadcafe.com developer portal:
http://www.eggheadcafe.com
UnBlog:
http://petesbloggerama.blogspot.com


"ma**@mailinato r.com" wrote:
Peter wrote:
Matt,
If you read the MSDN Documentation on the HttpResponse class, you'll find
all these methods clearly spelled out:

thanks.

but if MSDN made everything clear, id be expert on everything ive read
there, and nobody would buy books :)

while those are useful technical explainations of what each method
does, i dont know that i would say they clearly spell things out... for
example, when reading the "HttpResponse.C lear Method" entry, it says:

Remarks
The Clear method does not clear header information.

yet, in the code sample it says:

// Set the page's content type to JPEG files
// and clear all response headers.
Response.Conten tType = "image/jpeg";
Response.Clear( );

....which seem contradictory to me (does it clear headers, or doesnt it?
but more importantly -- *why* do i want to clear headers!?)

so i guess what im looking for is more of a "Well, the basic idea of X
is xxxx. You really only need to use X when doing Y..." type
discussion.

for instance, im going to send the user an .XLS -- why is it important
to clear the response headers (.ClearHeaders) from my event handler's
routine? or to use .Clear? omitting the lines seems to make no
difference in my test environment.

or, when is it to the developer's advantage to enable output buffering
on the response?
....so can anyone comment on these HttpResponse items in more of a
non-tech-specs, general-rules-of-thumb fashion?
thanks!
matt

Nov 22 '06 #4

Peter wrote:
Yep. I read this as you saying "I think I really need to study the HTTP
Protocol first". That will help, plenty of free tutorials on the web that
will explain what headers are, etc.
well, then i guess i view these groups a little differently. i was
hoping to initiate a discussion on the topic, not hunt the web for
articles. so you could say i wrote that saying, "I not an expert on
HTTP Protocol, and I'm not sure that I want to be. But, can anyone
offer the general gist of why these commands exist and when they are
actually necessary?"

im still interested in that sort of discussion, if any one cares to
chime in. if not, well then i guess there is a dead thread.
matt

Nov 22 '06 #5

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

Similar topics

3
13757
by: Zoury | last post by:
Hi folks ! :O) I'm trying to show a PDF in ASP.NET but I can't get to work properly. here's a portion of my code : '** Dim ms As MemoryStream = DirectCast(m_report.FormatEngine.ExportToStream(reqContext), MemoryStream) If (fileName Is Nothing) Then
0
1988
by: ProJee | last post by:
Hi, Response.WriteFile (or Response.OutputStream.Write) finishes immediately, not after the file is completely downloaded. It finishes before (!) the user clicks the "Save" or "Open" browser button, file size doesn't matter. I'm not possible to track if the file was completely downloaded or if the user only clicked the link and cancelled the download. I've created a simple "solution" of this problem, which waits until the
4
2223
by: Martin Feuersteiner | last post by:
Dear Group I'm new to http responses / requests and would be grateful if you can shed some light on this issue. Let's assume I've two pages, a.aspx and b.aspx. The buffer is set to false for both. a.aspx contains several controls, including a button control that will do a server.transfer to b.aspx. On b.aspx, I'm building a string (rtf document code) and send it to the
0
2980
by: PD | last post by:
I am trying to stream out a PDF file via the response object and when I execute the code it always brings up the first document that I pulled up.Even when I step through the code, I can see the new values in theData string array (see code below), but it serves up the first document that I had run this code with. I streamed theData into a text file to look at the values and it contained the appropriate ones for the new document. Even when I...
1
2534
by: Sridhar | last post by:
Hi, I am trying to display a pdf file on the web. It is working fine but the Page_Load method is running twice before displaying the page. Here is the code that I am using Private Sub ReadPdfFile(ByVal strFilepath As String) 'Create WebClient Object Dim objWebClient As New WebClient 'Create Byte Array to download data
3
28367
by: DC | last post by:
Hi, I am trying to load a pdf file into a memorystream and upload this file to the browser. However, wenn I run the attached code (the ftpStream is a valid stream of the pdf file) I receive an "Application error" in the Adobe Reader. I tried all the default encodings and the windows encoding (below) with the same result. TIA for any hint on what could be wrong here.
1
9329
by: ChristopherABurns | last post by:
I have a very simple code snippet here: private void Page_Load(object sender, System.EventArgs e) { string filePath = Server.MapPath("\\Transcriber\\TranscriberTest\\"); string fileName = "Test.Zip"; //FileInfo fi = new FileInfo(filePath + fileName); FileStream fs = File.Open(filePath + fileName,FileMode.Open);
2
3179
by: Michael D. Ober | last post by:
When I single step through the code below, it sends back the PDF file that is retrieved in the line fm.GetAccountPDF(...). When I run without single stepping, I get the master page for this page. I have actually saved the file returned by IE 7 as a text file and opened it in notepad, so I have confirmed that it is indeed the page master being returned. The code is in the code behind file for the aspx page and is called directly from a...
3
7120
by: =?Utf-8?B?enBlcmV0eg==?= | last post by:
Hallo, I Can't get reed of http response headers . Thow I used : Response.ClearHeaders witch MSDN say's it should clear up all http headers I'm on VS 2005 - windows xp IIS Thank you
0
7920
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
8401
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...
1
8054
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
8268
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
6730
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, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
5867
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
3900
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...
0
3944
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2418
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.