How to set the Content-Length header and it work in Cassini?

646 Views Asked by At

I'm working on a slightly low-level ASP.Net project. One of the things I need to support is properly handling HEAD requests. For the uninitiated, a HEAD request is basically just HTTP headers with no content.

Part of this includes a correct content-length. (Even though ASP.Net thinks that the content-length is 0)

I use this code for setting it:

HttpRequest r; .... 
if(r.Headers.AllKeys.Contains("Content-Length")){
    r.Headers["Content-Length"]=length.ToString();
}else{
    r.AddHeader("Content-Length",length.ToString());
}

This runs fine on mod_mono+Apache and on Mono's implementation of xsp, however, on Microsoft's Cassini dev server, this produces a PlatformNotSupportedException with the text This operation requires IIS integrated pipeline mode.

Are there any known workarounds for this issue?

0

There are 0 best solutions below