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

How to response from custom HttpHandler with "204 No Content"?

I'm developing asp.net 2 web application and need to make a custom
http handler which sometime must send response with "204 No Content"
code.
I set HttpResponse.Status="204 No Content"; But asp automatically adds
headers such as "Content-Length: 0".
This causes an error on the client. HttpResponse.ClearHeaders()
doesn't help. How to make asp not to add headers (especially Content-
Length)?

Thanks in advance.

Mar 21 '07 #1
3 7023
On Mar 21, 6:33 pm, "Alexander Smirnov" <s_alexande...@list.ruwrote:
I'm developing asp.net 2 web application and need to make a custom
http handler which sometime must send response with "204 No Content"
code.
I set HttpResponse.Status="204 No Content"; But asp automatically adds
headers such as "Content-Length: 0".
This causes an error on the client. HttpResponse.ClearHeaders()
doesn't help. How to make asp not to add headers (especially Content-
Length)?

Thanks in advance.
Try the following:

Response.StatusCode = 204;
Response.Flush();
Response.SuppressContent = true;

Mar 21 '07 #2
On Mar 22, 12:56 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:
On Mar 21, 6:33 pm, "Alexander Smirnov" <s_alexande...@list.ruwrote:
I'm developing asp.net 2 web application and need to make a custom
http handler which sometime must send response with "204 No Content"
code.
I set HttpResponse.Status="204 No Content"; But asp automatically adds
headers such as "Content-Length: 0".
This causes an error on the client. HttpResponse.ClearHeaders()
doesn't help. How to make asp not to add headers (especially Content-
Length)?
Thanks in advance.

Try the following:

Response.StatusCode = 204;
Response.Flush();
Response.SuppressContent = true;
Thanks! Now it doesn't send "Content-Length" header and no error
occurs on the client.
But there's another problem - it sends "Connection: close" even if I
do Response.AppendHeader("Connection","Keep-Alive"). And also it sends
some over headers. How to fully control headers in a custom http
handler (descendant of IHttpHandler)? In fact I don't wont any headers
to be sent, only the status line "HTTP/1.1 204 No Content\r\n\r\n" and
not to close the connection.

Mar 22 '07 #3
On Mar 22, 8:24 am, "Alexander Smirnov" <s_alexande...@list.ruwrote:
On Mar 22, 12:56 am, "Alexey Smirnov" <alexey.smir...@gmail.com>
wrote:


On Mar 21, 6:33 pm, "Alexander Smirnov" <s_alexande...@list.ruwrote:
I'm developing asp.net 2 web application and need to make a custom
http handler which sometime must send response with "204 No Content"
code.
I set HttpResponse.Status="204 No Content"; But asp automatically adds
headers such as "Content-Length: 0".
This causes an error on the client. HttpResponse.ClearHeaders()
doesn't help. How to make asp not to add headers (especially Content-
Length)?
Thanks in advance.
Try the following:
Response.StatusCode = 204;
Response.Flush();
Response.SuppressContent = true;

Thanks! Now it doesn't send "Content-Length" header and no error
occurs on the client.
But there's another problem - it sends "Connection: close" even if I
do Response.AppendHeader("Connection","Keep-Alive"). And also it sends
some over headers. How to fully control headers in a custom http
handler (descendant of IHttpHandler)? In fact I don't wont any headers
to be sent, only the status line "HTTP/1.1 204 No Content\r\n\r\n" and
not to close the connection.- Hide quoted text -

- Show quoted text -
Probably you have to rewrite it from the base class.

What is the problem exactly, why don't you like the "Connection:
close" in the response?

Mar 22 '07 #4

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

Similar topics

1
by: Sugapablo | last post by:
In the following file below, I want it to return itself as a Rich Text Format file that populates the variables with data from the database. I set up the mime types and the filename accordingly....
10
by: Blue® | last post by:
I would like to call the content of content.htm (containing only HTML codes) into index.htm. This is usually done by renaming index.htm to index.shtml and use this tag: <!--#include...
10
by: Michael Strorm | last post by:
Hi! I've been having problems with a DTD. Having had the Sun XML validator reject a document, I put it through 'xmllint' for more information. 'Xmllint' noted a problem with the DTD itself;...
12
by: Jean-Marc Blaise | last post by:
Hi Folks, I'm getting this message with the XML tutorial: getstart_exportXML.cmd file: SQL0444N Routine "DB2XML.CONTENT" (specific name "DB2XMLCONTENTVF") is implemented with code in library...
2
by: Sam | last post by:
I would like to put my help files and some other dependencies under source control and have them copy themselves to the Debug and Release paths automatically when the solution is built. .. I...
0
by: Patrick | last post by:
hi several general webpages (more or less static, e.g. errorpage, timeoutpage etc.) i need in all kind of asp.net-applications. instead of copy this pages (the *.aspx or *.html) into every...
1
by: Henry Law | last post by:
(I posted this to comp.infosystems.www.browsers.misc but there seems to be very little traffic there. I can't see another suitable group; is it on topic here? If not, any suggestions as to...
11
by: Trapulo | last post by:
I've this statement in my output's creation: Response.Clear() Response.ContentType = "application/vnd.google-earth.kml+xml kml" Response.AddHeader("Content-Disposition", "inline;...
1
by: dave8421 | last post by:
Hi, I'm trying to make sense of the definition for "Rendered Content" in current CR for CSS 2.1 Is rendered content what is displayed on the particular media or device? from the...
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
0
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...
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...

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.