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.